简体   繁体   English

paper.js点数学不起作用

[英]paper.js point math not working

Even though the paper.js documentation states that it is possible to do implicit additions on points or assignements with [x,y] (first block of code, line 17), I can not get this to work. 即使paper.js文档指出可以用[x,y] (第1行代码,第17行)对点或paper.js进行隐式加法 ,但我无法做到这一点。 Any point resulting from math of the type point3 = point2 - point1 has undefined x and y properties, whereas they are well defined in the points after creation with new . 数学类型为point3 = point2 - point1任何点都具有未定义的xy属性,而在使用new创建后的点中,它们定义良好。

I have created this JSFiddle to reproduce the errors I am getting. 我创建了这个JSFiddle来重现我得到的错误。

What have I missed in my code, please ? 请问我在代码中错过了什么?

The page you link to says: 您链接到页面显示

PaperScript code is loaded just like any other JavaScript using the <script> tag, except for the type being set to "text/paperscript" or "text/x-paperscript" . 就像使用<script>标记的所有其他JavaScript一样,加载PaperScript代码,除了将类型设置为"text/paperscript""text/x-paperscript" The code can either be an external file ( src="URL" ), or inlined: 该代码可以是外部文件( src="URL" ),也可以是内联的:

Once you put your code in a <script type="text/paperscript"> tag, it works: 将代码放在<script type="text/paperscript">标记中后,它将起作用:

jsfiddle.net/2F2jx/6 jsfiddle.net/2F2jx/6

Edit: To use a linked script, it's no different. 编辑:要使用链接的脚本,没有什么不同。 You set the type attribute: 您设置type属性:

<script type="text/paperscript" src="myscript.js"></script>

链接上的PaperJS为v0.22,最新版本为v0.9.12,因此,如果您使用在线参考http://paperjs.org/reference/,则您的代码适用于0.22版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM