Class Brush

A Brush holds color information and describes how to draw the inside of a Shape or the stroke of a shape or a TextBlock or the background of any GraphObject. A Brush must not be modified once it has been assigned to a GraphObject, such as the Shape#fill or TextBlock#stroke or GraphObject#background. However, a Brush may be shared by multiple GraphObjects.

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(type: EnumValue): Brush

Construct a Brush class of a given type.

Parameters

  • type: EnumValue

    one of the values Brush#Solid, Brush#Linear, Brush#Radial, Brush#Pattern.

Returns

Brush

constructor(color?: string): Brush

Construct a solid color Brush that holds the given color information.

Parameters

  • color?: string optional

    a well-formed CSS string describing a solid color brush; if not supplied uses 'black'.

Returns

Brush

Properties

public static Linear: EnumValue

For linear gradient brushes, used as the value for Brush#type.

public static Pattern: EnumValue

For pattern brushes, used as the value for Brush#type.

public static Radial: EnumValue

For radial gradient brushes, used as the value for Brush#type.

public static Solid: EnumValue

For simple, solid color brushes, used as the value for Brush#type.

public color: string

Gets or sets the color of a solid Brush.

public colorStops: Map

Gets or sets a Map holding all of the color stops used in this gradient, where the key is a number, the fractional distance between zero and one (inclusive), and where the corresponding value is a color string.

public end: Spot

Gets or sets the ending location for a linear or radial gradient.

public endRadius: number

Gets or sets the radius of a radial brush at the end location.

public pattern: any

Gets or sets the pattern of a brush of type Brush#Pattern, an HTMLImageElement or HTMLCanvasElement.

public start: Spot

Gets or sets the starting location for a linear or radial gradient.

public startRadius: number

Gets or sets the radius of a radial brush at the start location.

public type: EnumValue

Gets or sets the type of brush.

Methods

public addColorStop(loc: number, color: string): any

Specify a particular color at a particular fraction of the distance. If the #type is Brush#Solid, change the type to Brush#Linear. You should have a color stop at zero and a color stop at one. You should not have duplicate color stop values at the same fractional distance.

Parameters

  • loc: number

    between zero and one, inclusive.

  • color: string

    a CSS color string

Returns

any

public copy(): Brush

Create a copy of this Brush, with the same values.

Returns

Brush

public static randomColor(min?: number, max?: number): string

This static method can be used to generate a random color string.

Parameters

  • min?: number optional

    a number between zero and 255, defaults to 128.

  • max?: number optional

    a number between zero and 255, defaults to 255.

Returns

string