
在本教程中,我们将学习如何查找 Image 实例的复杂度 使用 FabricJS。我们可以通过创建fabric.Image的实例来创建一个Image对象。 由于它是FabricJS的基本元素之一,我们也可以轻松地自定义它 应用角度、不透明度等属性。为了找到图像的复杂度 例如,我们使用复杂性方法。如果当前对象是此方法将返回 1 直接从基类继承,而不是从子类继承。
语法
complexity(): Number
使用复杂性方法
示例
让我们看一个代码示例,看看使用complexity方法时记录的输出 获取 Image 实例的复杂度。除非进行子分类,否则复杂度为1。
Using the complexity method
You can open console from dev tools and see the logged output
![]()
使用复杂度方法来比较不同的对象
示例
在此示例中,我们使用了复杂度方法来比较 图像实例和多边形实例。您可以从开发工具打开控制台 看到复杂性是不同的。
Using the complexity method to compare different objects
You can open console from dev tools and see the logged output
![]()









