简体   繁体   English

Javascript fabric.js和原型

[英]Javascript fabric.js and prototype

In an example about Fabric.js available at: http://fabricjs.com/interaction-with-objects-outside-canvas 有关Fabric.js的示例,请参见: http ://fabricjs.com/interaction-with-objects-outside-canvas

The 3rd line reads: fabric.Object.prototype.transparentCorners = false; 第三行显示:fabric.Object.prototype.transparentCorners = false;

The property transparentCorners is already a property of the fabric.Object. 属性transparentCorners已经是fabric.Object的属性。 We are NOT adding it here. 我们不在这里添加它。

Why is there a need to add the word "prototype"? 为什么需要添加“原型”一词? I don't get the reason. 我不知道原因。 Since we are NOT adding a new property to fabric.Object, wouldn't be the same to write: fabric.Object.transparentCorners = false; 由于我们没有在fabric.Object中添加新属性,因此编写起来就不会一样:fabric.Object.transparentCorners = false;

Please explain the difference. 请说明差异。

Thank you 谢谢

Adding the property ( modifying the value of the property ) on the fabric.Object prototype allows you to get that property set for each instance of the object and objects extended from that one already set to that default value. 在fabric.Object原型上添加属性(修改属性的值),您可以为每个对象实例获取该属性集,并将对象从已经设置为默认值的对象扩展。

So each fabric.Rect and fabric.Triangle will have the property transparentCorners set to false. 因此,每个fabric.Rect和fabric.Triangle都将属性transparentCorners设置为false。

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

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