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:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name | URI | Brush identifier | ||
shape | Polygon|PathBuilding.Polygon|Rendering.2D.BrushPrototype|Array.<Rendering.2D.BrushPrototype> | |||
spacing | float | <optional> | 1 | separation between polygons |
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
encoding | Serialization.TypedArrayCodec.Encoding | <optional> | AUTO | Applicable for JSON serialization, configures shape serialization type |
Since:
- 3.0
Methods
(async) configure(ctx) → {Promise}
Loads shape and fill pixels
Parameters:
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D|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:
Name | Type | Description |
---|---|---|
data | JSON | Polygon brush data |
Returns:
Brush2D instance
Type
Type Definitions
ShapeDescriptor
Polygon shape descriptor
Properties:
Name | Type | Description |
---|---|---|
name | URI | Polygon identifier, used for serialization. When available BrushPrototype shape will not be serialized. URIResolver should provide Polygon shape when BrushPrototype is deserialized. |
value | Polygon | Polygon shape |
Type
Enumeration of the provided shapes
Properties:
Name | Type | Description |
---|---|---|
ELLIPSE | URI | Ellipse polygon descriptor |
CIRCLE | URI | Circle polygon descriptor |
STAR | URI | Star polygon descriptor |