# Two.Group
Extends: Two.Shape
This is the primary class for grouping objects that are then drawn in Two.js. In Illustrator this is a group, in After Effects it would be a Null Object. Whichever the case, the Two.Group
contains a transformation matrix and commands to style its children, but it by itself doesn't render to the screen.
# Constructor
Argument | Description |
---|---|
children | A list of objects that inherit Two.Shape. For instance, the array could be a Two.Path, Two.Text, and Two.RoundedRectangle. |
# InsertChildren
Two.Group.InsertChildren
Argument | Description |
---|---|
children | The objects to be inserted. |
Cached method to let renderers know children have been added to a Two.Group.
# RemoveChildren
Two.Group.RemoveChildren
Argument | Description |
---|---|
children | The objects to be removed. |
Cached method to let renderers know children have been removed from a Two.Group.
# OrderChildren
Two.Group.OrderChildren
Cached method to let renderers know order has been updated on a Two.Group.
# fill
Two.Group.fill
The value of what all child shapes should be filled in with.
See: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value (opens new window) for more information on CSS's colors as String
.
# stroke
Two.Group.stroke
The value of what all child shapes should be outlined in with.
See: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value (opens new window) for more information on CSS's colors as String
.
# cap
Two.Group.cap
# join
Two.Group.join
# miter
Two.Group.miter
# closed
Two.Group.closed
Determines whether a final line is drawn between the final point in the vertices
array and the first point of all child shapes.
# curved
Two.Group.curved
When the child's path is automatic = true
this boolean determines whether the lines between the points are curved or not.
# automatic
Two.Group.automatic
Determines whether or not Two.js should calculate curves, lines, and commands automatically for you or to let the developer manipulate them for themselves.
# beginning
Two.Group.beginning
Number between zero and one to state the beginning of where the path is rendered.
Two.Group.beginning is a percentage value that represents at what percentage into all child shapes should the renderer start drawing.
# ending
Two.Group.ending
Number between zero and one to state the ending of where the path is rendered.
Two.Group.ending is a percentage value that represents at what percentage into all child shapes should the renderer start drawing.
# additions
Two.Group.additions
An automatically updated list of children that need to be appended to the renderer's scenegraph.
# subtractions
Two.Group.subtractions
An automatically updated list of children that need to be removed from the renderer's scenegraph.
# clone
Two.Group.clone
Returns: Two.Group
Argument | Description |
---|---|
parent | The parent group or scene to add the clone to. |
Create a new instance of Two.Group with the same properties of the current group.
# toObject
Two.Group.toObject
Returns: Object
Return a JSON compatible plain object that represents the group.
# corner
Two.Group.corner
Orient the children of the group to the upper left-hand corner of that group.
# getById
Two.Group.getById
Returns: Two.Shape
- Or
null
if nothing is found.
Recursively search for id. Returns the first element found.
# getByClassName
Two.Group.getByClassName
Returns: Array.<Two.Shape>
- Or empty array if nothing is found.
Recursively search for classes. Returns an array of matching elements.
# getByType
Two.Group.getByType
Returns: Array.<Two.Shape>
- Empty array if nothing is found.
Recursively search for children of a specific type, e.g. Two.Path. Pass a reference to this type as the param. Returns an array of matching elements.
# add
Two.Group.add
Argument | Description |
---|---|
objects | An array of objects to be added. Can also be supplied as individual arguments. |
Add objects to the group.
# remove
Two.Group.remove
Argument | Description |
---|---|
objects | An array of objects to be removed. Can be also removed as individual arguments. If no arguments are passed, then it removes itself from its parent. |
Remove objects from the group.
# getBoundingClientRect
Two.Group.getBoundingClientRect
Returns: Object
- Returns object with top, left, right, bottom, width, height attributes.
Argument | Description |
---|---|
shallow | Describes whether to calculate off local matrix or world matrix. |
Return an object with top, left, right, bottom, width, and height parameters of the group.