Methods
(static) add(…object) → {Self}
Adds objects to collection, Canvas or Group, then renders canvas
(if `renderOnAddRemove` is not `false`).
in case of Group no changes to bounding box are made.
Objects should be instances of (or inherit from) fabric.Object
Use of this function is highly discouraged for groups.
you can add a bunch of objects with the add method but then you NEED
to run a addWithUpdate call for the Group class or position/bbox will be wrong.
将对象添加到集合、画布或组中,然后渲染画布
(如果' renderOnAddRemove '不是' false ')。
在Group的情况下,不改变边界框。
对象应该是fabric的实例(或从fabric继承)。对象
非常不建议群组使用此功能。
你可以用add方法添加一堆对象,但是你需要
为Group类或position/bbox运行addWithUpdate调用将是错误的。
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
fabric.Object |
<repeatable> |
Zero or more fabric instances零个或多个fabric实例 |
Returns:
thisArg
- Type
- Self
(static) complexity() → {Number}
Returns number representation of a collection complexity
返回集合复杂度的数字表示形式
Returns:
complexity
- Type
- Number
(static) contains(object, deepopt) → {Boolean}
Returns true if collection contains an object
如果集合包含对象则返回true
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
object |
Object | Object to check against核对对象 | ||
deep |
Boolean |
<optional> |
false | `true` to check all descendants, `false` to check only `_objects`' true '检查所有子类,' false '只检查' _objects ' |
Returns:
`true` if collection contains an object
- Type
- Boolean
(static) forEachObject(callback, context) → {Self}
Executes given function for each object in this group
对该组中的每个对象执行给定的函数
Parameters:
Name | Type | Description |
---|---|---|
callback |
function | Callback invoked with current object as first argument, index - as second and an array of all objects - as third. Callback is invoked in a context of Global Object (e.g. `window`) when no `context` argument is given以当前对象作为第一个参数调用的回调, 索引——作为第二,所有对象的数组——作为第三。 在全局对象的上下文中调用回调(Callback)。“窗口”) 当没有给出' context '参数时 |
context |
Object | Context (aka thisObject)背景(又名thisObject) |
Returns:
thisArg
- Type
- Self
(static) getObjects(typeopt) → {Array}
Returns an array of children objects of this instance
Type parameter introduced in 1.3.10
since 2.3.5 this method return always a COPY of the array;
返回此实例的子对象数组
1.3.10中引入的类型参数
自2.3.5起,此方法总是返回数组的COPY;
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
String |
<optional> |
When specified, only objects of this type are returned当指定时,只返回此类型的对象 |
Returns:
- Type
- Array
(static) insertAt(object, index, nonSplicing) → {Self}
Inserts an object into collection at specified index, then renders canvas (if `renderOnAddRemove` is not `false`)
An object should be an instance of (or inherit from) fabric.Object
Use of this function is highly discouraged for groups.
you can add a bunch of objects with the insertAt method but then you NEED
to run a addWithUpdate call for the Group class or position/bbox will be wrong.
将对象插入到指定索引的集合中,然后渲染画布(如果' renderOnAddRemove '不是' false ')
对象应该是fabric的实例(或从fabric继承)。对象
非常不建议群组使用此功能。
你可以用insertAt方法添加一堆对象,然后你需要
为Group类或position/bbox运行addWithUpdate调用将是错误的。
Parameters:
Name | Type | Description |
---|---|---|
object |
Object | Object to insert插入的对象 |
index |
Number | Index to insert object at插入对象的索引 |
nonSplicing |
Boolean | When `true`, no splicing (shifting) of objects occurs当为true时,不会发生对象的拼接(移位) |
Returns:
thisArg
- Type
- Self
(static) isEmpty() → {Boolean}
Returns true if collection contains no objects
如果集合中不包含任何对象,则返回true
Returns:
true if collection is empty
- Type
- Boolean
(static) item(index) → {Self}
Returns object at specified index
返回指定索引处的对象
Parameters:
Name | Type | Description |
---|---|---|
index |
Number |
Returns:
thisArg
- Type
- Self
(static) remove(…object) → {Self}
Removes objects from a collection, then renders canvas (if `renderOnAddRemove` is not `false`)
从集合中移除对象,然后渲染画布(如果' renderOnAddRemove '不是' false ')
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
fabric.Object |
<repeatable> |
Zero or more fabric instances零个或多个fabric实例 |
Returns:
thisArg
- Type
- Self
(static) size() → {Number}
Returns a size of a collection (i.e: length of an array containing its objects)
返回集合的大小(即:包含其对象的数组的长度)
Returns:
Collection size
- Type
- Number