Brush class

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.

Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

Brush([Object? type, dynamic init])
factory

Properties

color String

Available on Brush, provided by the Brush$Typings extension

Gets or sets the color of a solid Brush. The default value is 'black'. The value must be a valid CSS color string.
getter/setter pair
colorStops Map<num, String>?

Available on Brush, provided by the Brush$Typings extension

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.
getter/setter pair
end Spot

Available on Brush, provided by the Brush$Typings extension

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.
getter/setter pair
endRadius num

Available on Brush, provided by the Brush$Typings extension

Gets or sets the radius of a radial brush at the end location. The default value is NaN.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
pattern HTMLElement?

Available on Brush, provided by the Brush$Typings extension

Gets or sets the pattern of a brush of type Brush.Pattern.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
start Spot

Available on Brush, provided by the Brush$Typings extension

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.
getter/setter pair
startRadius num

Available on Brush, provided by the Brush$Typings extension

Gets or sets the radius of a radial brush at the start location. The default value is 0.
getter/setter pair
type EnumValue

Available on Brush, provided by the Brush$Typings extension

Gets or sets the type of brush. The default value is Brush.Solid. 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.
getter/setter pair

Methods

addColorStop(num loc, String color) Brush

Available on Brush, provided by the Brush$Typings extension

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 not have duplicate color stop values at the same fractional distance. @param {number} loc A number between 0 and 1 (inclusive). @param {string} color A valid CSS color string. @return {Brush} this Brush
copy() Brush

Available on Brush, provided by the Brush$Typings extension

Create a copy of this Brush with the same values. @return {Brush}
darkenBy([num? fraction, EnumValue? mode]) Brush

Available on Brush, provided by the Brush$Typings extension

Modifies all colors within this Brush, darkening them by some fraction. @param {number=} fraction Fraction to darken the colors by. Defaults to 0.2, must be between 0 and 1 (inclusive). @param {EnumValue=} mode Color space to use for adjusting. Must be Brush.Lab or Brush.HSL, defaults to Brush.Lab. @return {Brush} This Brush with modified color values. @since 1.7
isDark() bool

Available on Brush, provided by the Brush$Typings extension

This function determines whether this Brush is "dark." @return {boolean} @since 2.0
lightenBy([num? fraction, EnumValue? mode]) Brush

Available on Brush, provided by the Brush$Typings extension

Modifies all colors within this Brush, lightening them by some fraction. @param {number=} fraction Fraction to lighten the colors by. Defaults to 0.2, must be between 0 and 1 (inclusive). @param {EnumValue=} mode Color space to use for adjusting. Must be Brush.Lab or Brush.HSL, defaults to Brush.Lab. @return {Brush} This Brush with modified color values. @since 1.7
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

hsl EnumValue
For lightening and darkening, used as a color-space value.
getter/setter pair
lab EnumValue
For lightening and darkening, used as a color-space value.
getter/setter pair
linear EnumValue
For linear gradient brushes, used as the value for Brush#type.
getter/setter pair
pattern EnumValue
For pattern brushes, used as the value for Brush#type.
getter/setter pair
radial EnumValue
For radial gradient brushes, used as the value for Brush#type.
getter/setter pair
solid EnumValue
For simple, solid color brushes, used as the value for Brush#type.
getter/setter pair

Static Methods

darken(String color) String
This static function takes a color and darkens it by 20% in the Lab color space. This is a convenience function which calls Brush.darkenBy.
darkenBy(String color, [num? fraction, EnumValue? mode]) String
This static function takes a color and darkens it.
isDark(dynamic color) bool
This static function takes a color and determines whether it is "dark." Does not account for transparency.
isValidColor(String color) bool
This static function returns true if a given color string is well-formed for drawing.
lighten(String color) String
This static function takes a color and lightens it by 20% in the Lab color space. This is a convenience function which calls Brush.lightenBy.
lightenBy(String color, [num? fraction, EnumValue? mode]) String
This static function takes a color and lightens it.
mix(String color1, String color2, [num? fraction]) String
This static function takes two colors and mixes them together, using the (optionally) specified amount of the second color.
randomColor([num? min, num? max]) String
This static function can be used to generate a random color.