Methods
(static) add(…object) → {Self}
将对象添加到集合、画布或组中,然后渲染画布
(如果' renderOnAddRemove '不是' false ')。
在Group的情况下,不改变边界框。
对象应该是fabric的实例(或从fabric继承)。对象
非常不建议群组使用此功能。
你可以用add方法添加一堆对象,但是你需要
为Group类或position/bbox运行addWithUpdate调用将是错误的。
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
fabric.Object |
<repeatable> |
零个或多个fabric实例 |
Returns:
thisArg
- Type
- Self
(static) complexity() → {Number}
返回集合复杂度的数字表示形式
Returns:
complexity
- Type
- Number
(static) contains(object, deepopt) → {Boolean}
如果集合包含对象则返回true
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
object |
Object | 核对对象 | ||
deep |
Boolean |
<optional> |
false | ' true '检查所有子类,' false '只检查' _objects ' |
Returns:
`true` if collection contains an object
- Type
- Boolean
(static) forEachObject(callback, context) → {Self}
对该组中的每个对象执行给定的函数
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | 以当前对象作为第一个参数调用的回调, 索引——作为第二,所有对象的数组——作为第三。 在全局对象的上下文中调用回调(Callback)。“窗口”) 当没有给出' context '参数时 |
context |
Object | 背景(又名thisObject) |
Returns:
thisArg
- Type
- Self
(static) getObjects(typeopt) → {Array}
返回此实例的子对象数组
1.3.10中引入的类型参数
自2.3.5起,此方法总是返回数组的COPY;
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
String |
<optional> |
当指定时,只返回此类型的对象 |
Returns:
- Type
- Array
(static) insertAt(object, index, nonSplicing) → {Self}
将对象插入到指定索引的集合中,然后渲染画布(如果' renderOnAddRemove '不是' false ')
对象应该是fabric的实例(或从fabric继承)。对象
非常不建议群组使用此功能。
你可以用insertAt方法添加一堆对象,然后你需要
为Group类或position/bbox运行addWithUpdate调用将是错误的。
Parameters:
Name | Type | Description |
---|---|---|
object |
Object | 插入的对象 |
index |
Number | 插入对象的索引 |
nonSplicing |
Boolean | 当为true时,不会发生对象的拼接(移位) |
Returns:
thisArg
- Type
- Self
(static) isEmpty() → {Boolean}
如果集合中不包含任何对象,则返回true
Returns:
true if collection is empty
- Type
- Boolean
(static) item(index) → {Self}
返回指定索引处的对象
Parameters:
Name | Type | Description |
---|---|---|
index |
Number |
Returns:
thisArg
- Type
- Self
(static) remove(…object) → {Self}
从集合中移除对象,然后渲染画布(如果' renderOnAddRemove '不是' false ')
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
fabric.Object |
<repeatable> |
零个或多个fabric实例 |
Returns:
thisArg
- Type
- Self
(static) size() → {Number}
返回集合的大小(即:包含其对象的数组的长度)
Returns:
Collection size
- Type
- Number