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 ')。
在组的情况下,没有改变包围框。
对象应该是fabric的实例(或继承)。对象
强烈建议对组使用此函数。
你可以用add方法添加一些对象,但你需要
为Group类或position/ box运行addWithUpdate调用将是错误的。
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
fabric.Object |
<repeatable> |
Zero or more fabric instances0个或多个结构实例 |
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将当前对象作为第一个参数调用的回调函数, 索引-作为第二和所有对象的数组-作为第三。 回调函数是在全局对象的上下文中调用的。“窗口”) 当没有给出“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开始,这个方法总是返回数组的副本;
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/ box运行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 instances0个或多个结构实例 |
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