javascript - 将 paperjs 与 jsfiddle 一起使用

标签 javascript html jsfiddle paperjs

我刚刚发现 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/

相关文章:

javascript - Jquery mobile Click 事件未触发

javascript - 在 sortablejs 中保存和重置顺序

javascript - 舍入 n * 10 的算法

javascript - 如何隐藏 url 不出现在地址栏中(使用 javascript)

html - 使用媒体查询 Bootstrap 使列居中

android - JSfiddle : how to create multi-JS/CSS/HTML files project?

Javascript 计时器只是分钟和秒

css - 为什么我的 css 字体没有改变?

html - 响应式导航错误

css - CSS 是否有禁止尾随零的规则?