Gradient

Source: AWT.js:385

Contains parameters and methods to draw complex color gradients


Constructor

new Gradient( c1: string, c2: string, angle?: number, cycles?: number, ): Gradient

Gradient constructor

Parameters

  • c1 (string) — The initial color, in any CSS-valid form.
  • c2 (string) — The final color, in any CSS-valid form.
  • angle (number, optional, default: 0) — The inclination of the gradient relative to the horizontal line.
  • cycles (number, optional, default: 1) — The number of times the gradient will be repeated.

Instance Methods

setProperties($xml: external:jQuery): module:AWT.Gradient

Reads the properties of this Gradient from an XML element

Parameters

Returns

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

  • object

setAttributes(data: object): module:AWT.Gradient

Reads the properties of this Gradient from a data object

Parameters

  • data (object) — The data object to be parsed

Returns

getGradient( ctx: external:CanvasRenderingContext2D, rect: module:AWT.Rectangle, ): module:AWT.Gradient

Creates a CanvasGradient
based on the provided context and rectangle.

Parameters

Returns

getCss(): string

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

Returns

  • string

hasTransparency(): boolean

Checks if any of the gradient colors has transparency

Returns

  • boolean

Instance Fields

c1: string

Initial color

c2: string

Final color

angle: number

Tilt angle

cycles: number

Number of repetitions of the gradient