2013-09-25 19 views
0

我剛剛發現了大約paperjs,這是一個很棒的矢量圖形框架,您可能已經聽說過。與jsfiddle一起使用paperjs

雖然我偶然發現了一個問題,但我完全無法弄清楚如何使它與jsfiddle一起工作!我在網上找到的幾個例子只能工作,因爲所有的代碼都被卡在HTML部分,在一個paperscript標籤中。

任何想法如何使「Javascript」部分工作,從而使用語法着色?

非常感謝!

+0

您可以張貼在那裏你已嘗試使用PaperJS的的jsfiddle的鏈接? – Voles

回答

1

默認情況下,您不能將您的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/

+0

非常感謝,正是我一直在尋找的! – Cafe

+0

我得到這個錯誤:「拒絕執行腳本...因爲它的MIME類型(文本/純文本)不可執行,並且啓用了嚴格的MIME類型檢查。」但是我發現了一個解決方案[here](http://stackoverflow.com/a/18049842/696973),它說raw.github應該改爲rawgithub並更新你的小提琴:http://jsfiddle.net/LrGEm/317/ – Christoph

0

或者,您可以使用https://www.jsbin.com來進行編碼。它將允許JS寫入JavaScript佔位符。

+0

我從來沒有聽說過jsbin,它似乎是jsfiddle的好選擇! 你能否更清楚地解釋如何在jsbin中使用paperscript?仍然似乎無法使它工作,並且jsfiddle真的很起來。 – Cafe