AWT. Gradient

Contains parameters and methods to draw complex color gradients

Constructor

new Gradient(c1, c2, angleopt, cyclesopt)

Gradient constructor

Parameters:
NameTypeAttributesDefaultDescription
c1string

The initial color, in any CSS-valid form.

c2string

The final color, in any CSS-valid form.

anglenumber<optional>
0

The inclination of the gradient relative to the horizontal line.

cyclesnumber<optional>
1

The number of times the gradient will be repeated.

Members

angle :number

Tilt angle

Type:
  • number

c1 :string

Initial color

Type:
  • string

c2 :string

Final color

Type:
  • string

cycles :number

Number of repetitions of the gradient

Type:
  • number

Methods

getAttributes() → {object}

Gets a object with the basic attributes needed to rebuild this instance excluding functions,
parent references, constants and also attributes retaining the default value.
The resulting object is commonly usued to serialize elements in JSON format.

Returns:
  • The resulting object, with minimal attrributes
Type: 
object

getCss() → {string}

Gets the CSS 'linear-gradient' expression of this Gradient

Returns:
  • A string ready to be used as a value for the linear-gradient CSS attribute
Type: 
string

getGradient(ctx, rect) → {module:AWT.Gradient}

Creates a CanvasGradient
based on the provided context and rectangle.

Parameters:
NameTypeDescription
ctxexternal:CanvasRenderingContext2D

The 2D rendering context

rectmodule:AWT.Rectangle

The rectangle where this gradient will be applied to

Returns:
Type: 
module:AWT.Gradient

hasTransparency() → {boolean}

Checks if any of the gradient colors has transparency

Returns:
  • true if this gradient uses colors with transparency, false otherwise.
Type: 
boolean

setAttributes(data) → {module:AWT.Gradient}

Reads the properties of this Gradient from a data object

Parameters:
NameTypeDescription
dataobject

The data object to be parsed

Returns:
Type: 
module:AWT.Gradient

setProperties($xml) → {module:AWT.Gradient}

Reads the properties of this Gradient from an XML element

Parameters:
NameTypeDescription
$xmlexternal:jQuery

The xml element to be parsed

Returns:
Type: 
module:AWT.Gradient