- Home
- Learn
- Samples
- Intro
- API
- Register
- Download
- Forum
- Contact
- Buy
- Activate

GoJS Class Index

## Diagram Classes

- Adornment
- AnimationManager
- CommandHandler
- Diagram
- DiagramEvent
- GraphObject
- Group
- InputEvent
- Layer
- Link
- Node
- Overview
- Palette
- Panel
- Part
- Picture
- Placeholder
- RowColumnDefinition
- Shape
- TextBlock

## Geometry Classes

- Brush
- Geometry
- Margin
- PathFigure
- PathSegment
- Point
- Rect
- Size
- Spot

## Model Classes

- Binding
- ChangedEvent
- GraphLinksModel
- Model
- Transaction
- TreeModel
- UndoManager

## Layout Classes

- CircularLayout
- ForceDirectedLayout
- GridLayout
- LayeredDigraphLayout
- Layout
- LayoutNetwork
- TreeLayout

## Tool Classes

- ActionTool
- ClickCreatingTool
- ClickSelectingTool
- ContextMenuTool
- DraggingTool
- DragSelectingTool
- LinkingBaseTool
- LinkingTool
- LinkReshapingTool
- PanningTool
- RelinkingTool
- ResizingTool
- RotatingTool
- TextEditingTool
- Tool
- ToolManager

## Collection Classes

- Iterable
- Iterator
- List
- Map
- Set

GoJS® Diagramming Components
version 1.5.20 for JavaScript/HTML
by Northwoods Software®

# 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.<number,string>} | 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

{Brush}

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.