Skip to main content

Class: Brush2D

Rendering.2D.Brush2D(name, shape, spacingopt)

Strokes drawn with this brush will be drawn using polygon as a shape

Constructor

new Brush2D(name, shape, spacingopt)

Parameters:
NameTypeAttributesDefaultDescription
nameURIBrush identifier
shapePolygon|PathBuilding.Polygon|Rendering.2D.BrushPrototype|Array.<Rendering.2D.BrushPrototype>
spacingfloat<optional>1separation between polygons
Properties:
NameTypeAttributesDefaultDescription
encodingSerialization.TypedArrayCodec.Encoding<optional>AUTOApplicable for JSON serialization, configures shape serialization type

Since:

  • 3.0

Methods

(async) configure(ctx) → {Promise}

Loads shape and fill pixels

Parameters:
NameTypeDescription
ctxCanvasRenderingContext2D|OffscreenCanvasRenderingContext2D
Returns:

resolves fill

Type

Promise

toJSON() → {JSON}

Serialize to JSON

Returns:

Polygon brush data

Type

JSON

(static) fromJSON(data) → Rendering.2D.Brush2D

Deserialize from JSON

Parameters:
NameTypeDescription
dataJSONPolygon brush data
Returns:

Brush2D instance

Type

Rendering.2D.Brush2D

Type Definitions

ShapeDescriptor

Polygon shape descriptor

Properties:
NameTypeDescription
nameURIPolygon identifier, used for serialization. When available BrushPrototype shape will not be serialized. URIResolver should provide Polygon shape when BrushPrototype is deserialized.
valuePolygonPolygon shape

Type

Enumeration of the provided shapes

Properties:
NameTypeDescription
ELLIPSEURIEllipse polygon descriptor
CIRCLEURICircle polygon descriptor
STARURIStar polygon descriptor

Home