我刚刚发现 paperjs ,一个很棒的矢量图形框架,您可能已经听说过。
虽然我偶然发现了一个问题,但我绝对不知道如何让它与 jsfiddle 一起工作!我在网上找到的几个示例之所以有效,是因为所有代码都塞在 HTML 部分的 paperscript 标记中。
知道如何使“Javascript”部分起作用,从而利用语法着色吗?
非常感谢!
最佳答案
默认情况下,您不能将 paperjs 代码放在 javascript 面板中。 你需要破解 jsFiddler 才能做到这一点。 参见 the document from jsFiddler
Please set the Code Wrap to no wrap(head) (default is onLoad) and Franework to No-library (pure JS).
Similar to CoffeeScript, Paperscript requires the script tag to be the type of text/paperscript and provide the id of the canvas element in the canvas parameter. Enter following into the HTML panel and you’ll be able to write Paperscript in JavaScript panel.
<canvas id="some-unique-id" resize keepalive="true" style='height: 200; width: 200;'> </canvas>
<script>(function(){var s="script",n='\n',d=document,b=d.getElementsByTagName(s)[2].innerHTML.split(n);d.write('<'+s+' type="text/paperscript" canvas="' + document.getElementsByTagName('canvas')[0].id + '">'+b.slice(2,b.length-2).join(n)+'</'+s+'>')})()</script>
Example: http://jsfiddle.net/zalun/LrGEm/12/
关于javascript - 将 paperjs 与 jsfiddle 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19000944/