# Two.Gradient
Extends: Two.Element
This is the base class for constructing different types of gradients with Two.js. The two common gradients are Two.LinearGradient and Two.RadialGradient.
# Constructor
| Argument | Description |
|---|---|
| stops | A list of Two.Stops that contain the gradient fill pattern for the gradient. |
# fromObject
Two.Gradient.fromObject
Returns: Two.Gradient
| Argument | Description |
|---|---|
| obj | Object notation of a Two.Gradient to create a new instance |
Create a new Two.Gradient from an object notation of a Two.Gradient.
# spread
Two.Gradient.spread
Indicates what happens if the gradient starts or ends inside the bounds of the target rectangle. Possible values are 'pad', 'reflect', and 'repeat'.
See: https://www.w3.org/TR/SVG11/pservers.html#LinearGradientElementSpreadMethodAttribute (opens new window) for more information
# units
Two.Gradient.units
Indicates how coordinate values are interpreted by the renderer. Possible values are 'userSpaceOnUse' and 'objectBoundingBox'.
See: https://www.w3.org/TR/SVG11/pservers.html#RadialGradientElementGradientUnitsAttribute (opens new window) for more information
# clone
Two.Gradient.clone
Returns: Two.Gradient
| Argument | Description |
|---|---|
| parent | The parent group or scene to add the clone to. |
Create a new instance of Two.Gradient with the same properties of the current path.
# copy
Two.Gradient.copy
| Argument | Description |
|---|---|
| gradient | The reference Two.Gradient |
Copy the properties of one Two.Gradient onto another.
# toObject
Two.Gradient.toObject
Returns: Object
Return a JSON compatible plain object that represents the path.
# dispose
Two.Gradient.dispose
Detach instance from renderer including any <defs /> or textures stored in memory.