Construct a Brush class that holds the given color information.
Optionaltype: string | BrushTypeOptional, one of the values BrushType.Solid, BrushType.Linear, BrushType.Radial, BrushType.Pattern, or a well-formed CSS string describing a solid color brush. No argument defaults to a BrushType.Solid with a color description of 'black'.
Optionalinit: Partial<Brush> & Record<number, string>Optional initialization properties.
In addition to Brush properties, this object can also contain color stops in the format:
{ 0: "#FEC901", 0.2: "#FFFFAA", 1: "#FEA200" }
Such numeric property names result in calls to Brush.addColorStop.
Gets or sets the color of a solid Brush. The default value is 'black'. The value must be a valid CSS color string.
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 0 and 1 (inclusive), and where the corresponding value is a color string.
Call addColorStop in order to add color stops to this brush. This property value may be null if no gradient stops have been defined.
Gets or sets the ending location for a linear or radial gradient. A Spot value specifies a relative point in the object's GraphObject.naturalBounds. The default value is Spot.BottomCenter for linear gradients and Spot.Center for radial gradients.
Gets or sets the radius of a radial brush at the end location. The default value is NaN.
Gets or sets the pattern of a brush of type BrushType.Pattern.
Gets or sets the starting location for a linear or radial gradient. A Spot value specifies a relative point in the object's GraphObject.naturalBounds. The default value is Spot.TopCenter for linear gradients and Spot.Center for radial gradients.
Gets or sets the radius of a radial brush at the start location. The default value is 0.
Gets or sets the type of brush. The default value is BrushType.Solid. The value must be a BrushType. 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.
Specify a particular color at a particular fraction of the distance. If the type is BrushType.Solid, change the type to BrushType.Linear. You should not have duplicate color stop values at the same fractional distance.
A number between 0 and 1 (inclusive).
A valid CSS color string.
this Brush
Create a copy of this Brush with the same values.
Modifies all colors within this Brush, darkening them by some fraction.
Optionalfraction: numberFraction to darken the colors by. Defaults to 0.2, must be between 0 and 1 (inclusive).
Optionalmode: ColorSpaceColor space to use for adjusting. Must be a ColorSpace value, defaults to ColorSpace.Oklch.
This Brush with modified color values.
This function determines whether this Brush is "dark."
since2.0
Modifies all colors within this Brush, lightening them by some fraction.
Optionalfraction: numberFraction to lighten the colors by. Defaults to 0.2, must be between 0 and 1 (inclusive).
Optionalmode: ColorSpaceColor space to use for adjusting. Must be a ColorSpace value, defaults to ColorSpace.Oklch.
This Brush with modified color values.
StaticdarkenThis static function takes a color and darkens it by 20% in the Lab color space. This is a convenience function which calls Brush.darkenBy.
A valid CSS color string.
A CSS string for the darkened color in RGBA.
StaticdarkenThis static function takes a color and darkens it.
A valid CSS color string
Optionalfraction: numberFraction to darken the color by. Defaults to 0.2, must be between 0 and 1 (inclusive).
Optionalmode: ColorSpaceColor space to use for adjusting. Must be a ColorSpace value, defaults to ColorSpace.Oklch.
A CSS string for the darkened color in RGBA or HSLA.
StaticisThis static function takes a color and determines whether it is "dark." Does not account for transparency.
Example usage:
myDiagram.nodeTemplate =
new go.Node('Auto')
.add(
new go.Shape('RoundedRectangle', { strokeWidth: 0 })
.bind('fill', 'color'),
new go.TextBlock({ margin: 8 })
// Dark nodes use white text, light nodes use black text
.bind('stroke', 'color', c => go.Brush.isDark(c) ? 'white' : 'black')
.bind('text', 'key')
);
A valid CSS color string or a Brush.
since2.0
StaticisThis static function returns true if a given color string is well-formed for drawing. Such a string can be used as the value of any BrushLike property, such as Shape.fill, Shape.stroke, TextBlock.stroke, or GraphObject.background.
A color string to validate.
StaticlightenThis static function takes a color and lightens it by 20% in the Lab color space. This is a convenience function which calls Brush.lightenBy.
A valid CSS color string.
A CSS string for the lightened color in RGBA.
StaticlightenThis static function takes a color and lightens it.
A valid CSS color string.
Optionalfraction: numberFraction to lighten the colors by. Defaults to 0.2, must be between 0 and 1 (inclusive).
Optionalmode: ColorSpaceColor space to use for adjusting. Must be a ColorSpace value, defaults to ColorSpace.Oklch.
A CSS string for the lightened color in RGBA or HSLA.
StaticmixThis static function takes two colors and mixes them together, using the (optionally) specified amount of the second color.
A valid CSS color string.
Another valid CSS color string to mix.
Optionalfraction: numberFraction specifying how much color2 to mix into color1. Defaults to .5, must be between 0 and 1 (inclusive).
since2.0
StaticrandomThis static function can be used to generate a random color.
Optionalmin: numberA number between 0 and 255, defaults to 128.
Optionalmax: numberA number between 0 and 255, defaults to 255.
A color value in # hexadecimal format.
Static ReadonlyHSLdeprecatedSee ColorSpace.HSL.
Static ReadonlyLabdeprecatedSee ColorSpace.Lab.
Static ReadonlyLineardeprecatedSee BrushType.Linear.
Static ReadonlyPatterndeprecatedSee BrushType.Pattern.
Static ReadonlyRadialdeprecatedSee BrushType.Radial.
Static ReadonlySoliddeprecatedSee BrushType.Solid.
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.