[英]How do I translate JavaScript constructors to Amber Smalltalk?
I use the paperjs graphical objects library with Amber Smalltalk . 我使用带有Amber Smalltalk的paperjs图形对象库。
I want to translate the following Javascript constructors for a Point object to Amber Smalltalk 我想将Point对象的以下Javascript构造函数转换为Amber Smalltalk
paper.Point(x, y)
paper.Point(array)
paper.Point(object)
paper.Point(size)
paper.Point(point)
The following Smalltalk 以下Smalltalk
paper Point new inspect
gives a point 给出了一个观点
{ x: 0, y: 0 }
To construct an array in an Amber workspace I do 要在Amber工作区中构建数组,我这样做
#(100 100)
The printIt is printIt是
an Array (100 100)
However 然而
paper Point value: #(100 100)
gives nil as the result. 结果为零。
Question 题
How do I translate the paper.Point(array)
constructor from JavaScript to Amber as well as the other constructurs? 如何将
paper.Point(array)
构造函数从JavaScript转换为Amber以及其他构造函数?
References 参考
The Amber Smalltalk equivalent of new paper.Paper(100,100)
(JavaScript) is 琥珀Smalltalk相当于
new paper.Paper(100,100)
(JavaScript)是
paper Point newValue: 100 value: 100
This gives 这给了
{ x: 100, y: 100 }
Reference 参考
https://github.com/amber-smalltalk/amber/wiki/Call-javascript-constructors-with-arguments https://github.com/amber-smalltalk/amber/wiki/Call-javascript-constructors-with-arguments
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.