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
Name | Description |
---|---|
Brush(type)
|
Construct a Brush class that holds the given color information.More...
|
Properties Summary Details
Name, Value Type | Description |
---|---|
color
{string}
|
Gets or sets the color of a solid Brush. |
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.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. |
end
{Spot}
|
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. |
endRadius
{number}
|
Gets or sets the radius of a radial brush at the end location.More... The default value is NaN. |
pattern
{HTMLCanvasElement|HTMLImageElement}
|
Gets or sets the pattern of a brush of type Brush.Pattern.More... Must be a reference to an HTMLCanvasElement or HTMLImageElement. |
start
{Spot}
|
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. |
startRadius
{number}
|
Gets or sets the radius of a radial brush at the start location.More... This defaults to zero. |
type
{EnumValue}
|
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
Name, Return Type | 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.
|
copy()
{Brush}
|
Create a copy of this Brush, with the same values.
|
<static>
Brush.darken(color)
{string}
1.7
|
This static function takes a color and darkens it by 20% in the Lab color space.More... This is a convenience function which calls Brush.darkenBy.
|
darkenBy(fraction, mode)
{Brush}
1.7
|
Modifies all colors within this Brush, darkening them by some fraction.More...
|
<static>
Brush.darkenBy(color, fraction, mode)
{string}
1.7
|
This static function takes a color and darkens it.More...
|
<static>
Brush.isValidColor(color)
{boolean}
1.7
|
This static function returns true if a given color string is well-formed for drawing.More...
|
<static>
Brush.lighten(color)
{string}
1.7
|
This static function takes a color and lightens it by 20% in the Lab color space.More... This is a convenience function which calls Brush.lightenBy.
|
<static>
Brush.lightenBy(color, fraction, mode)
{string}
1.7
|
This static function takes a color and lightens it.More...
|
lightenBy(fraction, mode)
{Brush}
1.7
|
Modifies all colors within this Brush, lightening them by some fraction.More...
|
<static>
Brush.randomColor(min, max)
{string}
|
This static function can be used to generate a random color.More...
|
Constants Summary Details
Name | Description |
---|---|
HSL
{EnumValue}
|
For lightening and darkening, used as a color-space value. |
Lab
{EnumValue}
|
For lightening and darkening, used as a color-space value. |
Linear
{EnumValue}
|
For linear gradient brushes, used as the value for Brush.type. |
Pattern
{EnumValue}
|
For pattern brushes, used as the value for Brush.type. |
Radial
{EnumValue}
|
For radial gradient brushes, used as the value for Brush.type. |
Solid
{EnumValue}
|
For simple, solid color brushes, used as the value for Brush.type. |