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

ArgumentDescription
stopsA list of Two.Stops that contain the gradient fill pattern for the gradient.

fromObject

Returns: Two.Gradient

ArgumentDescription
objObject notation of a Two.Gradient to create a new instance

Create a new Two.Gradient from an object notation of a Two.Gradient.

nota-bene

Works in conjunction with Two.Gradient.toObject

spread

Indicates what happens if the gradient starts or ends inside the bounds of the target rectangle. Possible values are 'pad', 'reflect', and 'repeat'.

units

Indicates how coordinate values are interpreted by the renderer. Possible values are 'userSpaceOnUse' and 'objectBoundingBox'.

stops

An ordered list of Two.Stops for rendering the gradient.

clone

Returns: Two.Gradient

ArgumentDescription
parentThe 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

ArgumentDescription
gradientThe reference Two.Gradient

Copy the properties of one Two.Gradient onto another.

toObject

Returns: Object

Return a JSON compatible plain object that represents the path.

dispose

Detach instance from renderer including any <defs /> or textures stored in memory.