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.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
fabric.Object |
<repeatable> |
Zero or more fabric instances |
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
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` |
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 |
Object | Context (aka 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;
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.
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 |
Returns:
thisArg
- Type
- Self
(static) isEmpty() → {Boolean}
Returns true if collection contains no objects
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`)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
object |
fabric.Object |
<repeatable> |
Zero or more fabric instances |
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