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.

Constructor Summary Details

Returns Name Description
 
Brush(type)
Construct a Brush class that holds the given color information. More...
Parameters:
{EnumValue|string=} type
Optional, one of the values Brush.Solid, Brush.Linear, Brush.Radial, Brush.Pattern, or a well-formed CSS string describing a solid color brush. No parameter defaults to a Brush.Solid with a color description of 'black'.

Properties Summary Details

Returns Name Description
{string}
color
Gets or sets the color of a solid Brush.
{Map.}
colorStops
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. More...

Call addColorStop in order to add color stops to this brush. This property value may be null if no gradient stops have been defined.

{Spot}
end
Gets or sets the ending location for a linear or radial gradient. More... A Spot value specifies a relative point in the object's GraphObject.naturalBounds. This defaults to Spot.BottomCenter for linear gradients and Spot.Center for radial gradients.
{number}
endRadius
Gets or sets the radius of a radial brush at the end location. More... The default value is NaN.
{HTMLCanvasElement|HTMLImageElement}
pattern
Gets or sets the pattern of a brush of type Brush.Pattern. More... Must be a reference to an HTMLCanvasElement or HTMLImageElement.
{Spot}
start
Gets or sets the starting location for a linear or radial gradient. More... A Spot value specifies a relative point in the object's GraphObject.naturalBounds. This defaults to Spot.TopCenter for linear gradients and Spot.Center for radial gradients.
{number}
startRadius
Gets or sets the radius of a radial brush at the start location. More... This defaults to zero.
{EnumValue}
type
Gets or sets the type of brush. More... The value must be one of: Brush.Solid, Brush.Linear, Brush.Radial, Brush.Pattern. If the new value is a linear or radial brush type, and if the start or end spots are not specific spots, they are changed to be specific spots, depending on the type of brush.

Method Summary Details

Returns Name Description
addColorStop(loc, color)
Specify a particular color at a particular fraction of the distance. More... 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:
{number} loc
between zero and one, inclusive.
{string} color
copy()
Create a copy of this Brush, with the same values.
Returns:
{Brush}
<static> {string}
Brush.randomColor(min, max)
This static function can be used to generate a random color. More...
Parameters:
{number=} min
a number between zero and 255, defaults to 128.
{number=} max
a number between zero and 255, defaults to 255.
Returns:
{string} a color value in # hexadecimal format.

Constants Summary Details

Returns Name Description
<constant> {EnumValue}
Linear
For linear gradient brushes, used as the value for Brush.type.
<constant> {EnumValue}
Pattern
For pattern brushes, used as the value for Brush.type.
<constant> {EnumValue}
Radial
For radial gradient brushes, used as the value for Brush.type.
<constant> {EnumValue}
Solid
For simple, solid color brushes, used as the value for Brush.type.