Class Gradient<S, T>

Gradient class

Type Parameters

Hierarchy

  • Gradient

Constructors

Properties

colorStops: ColorStop[]

Defines how many colors a gradient has and how they are located on the axis defined by coords

coords: GradientCoords<T>

Defines how the gradient is located in space and spread

excludeFromExport?: boolean

If true, this object will not be exported during the serialization of a canvas

gradientTransform?: TMat2D

A transform matrix to apply to the gradient before painting. Imported from svg gradients, is not applied with the current transform in the center. Before this transform is applied, the origin point is at the top left corner of the object plus the addition of offsetY and offsetX.

Default

null
gradientUnits: GradientUnits

coordinates units for coords. If pixels, the number of coords are in the same unit of width / height. If set as percentage the coords are still a number, but 1 means 100% of width for the X and 100% of the height for the y. It can be bigger than 1 and negative. allowed values pixels or percentage.

Default

'pixels'
id: string | number

ID used for SVG export functionalities

offsetX: number

Horizontal offset for aligning gradients coming from SVG when outside pathgroups

Default

0
offsetY: number

Vertical offset for aligning gradients coming from SVG when outside pathgroups

Default

0
type: T

Gradient type linear or radial

Default

'linear'
type: string = 'Gradient'

Methods

  • Returns an instance of CanvasGradient

    Parameters

    • ctx: CanvasRenderingContext2D

      Context to render on

    Returns CanvasGradient

  • Returns object representation of a gradient

    Parameters

    • Optional propertiesToInclude: string[]

      Any properties that you might want to additionally include in the output

    Returns Partial<Gradient<S, T>> & {
        colorStops: ColorStop[];
        coords: GradientCoords<T>;
        gradientTransform: undefined | number[];
        gradientUnits: GradientUnits;
        offsetX: number;
        offsetY: number;
        type: T;
    }

Generated using TypeDoc