Class: BrushGL
Rendering.WebGL.BrushGL(name, shape, fill, particleSettings, fillTextureSettings)
Strokes drawn with this brush will be drawn using a large number of small textures (called particles), scattered along the stroke's trajectory.This brush is much more computational heavy compared to the SolidColorBrush but it allows to create visualy expressive strokes.This brush will draw a large number of small images (defined by the shapeTextureId) along the stroke's path.Then they will be filled by repeating the image defined by the fillTexture.The distance between the particles is controlled by the spacing property.The value of the spacing must be greater than 0. Value of 1.0 means that the distance between two particles will be equal the average width of the two particles.The particles could also spread out sideways. This is controlled by the scattering property.Value of 0 means no spreading. Value of 1, means that the particles will spread out with a random amount between zero and one time of their width.The shape texture could be rotated randomly or by trajectory.
Constructor
new BrushGL(name, shape, fill, particleSettings, fillTextureSettings)
Parameters:
Name | Type | Description |
---|---|---|
name | URI | Brush identifier |
shape | ImageSRC|Rendering.WebGL.BrushGL.ImageDescriptor|Array.<(ImageSRC|Rendering.WebGL.BrushGL.ImageDescriptor)> | Valid image src or descriptor that will be used as a pixel source or mipmap array |
fill | ImageSRC|Rendering.WebGL.BrushGL.ImageDescriptor | Valid image src or descriptor that will be used as a pixel source |
particleSettings | Rendering.WebGL.BrushGL.ParticleSettings | Particle configuration |
fillTextureSettings | Rendering.WebGL.BrushGL.FillTextureSettings | Fill texture options |
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
encoding | Serialization.TypedArrayCodec.Encoding | <optional> | AUTO | Applicable for JSON serialization, configures shape and fill serialization type |
Since:
- 1.0
Methods
(async) configure(ctx) → {Promise}
Loads shape and fill pixels
Parameters:
Name | Type | Description |
---|---|---|
ctx | WebGLRenderingContext|WebGL2RenderingContext |
Returns:
resolves loaded pixels
Type
Promise
(async) getFillBinary() → {ArrayBuffer}
Load fill resource as binary
Returns:
fill
Type
ArrayBuffer
(async) getShapeBinary() → {ArrayBuffer|Array.<ArrayBuffer>}
Load shape resource/resources as binary
Returns:
shape
Type
ArrayBuffer|Array.<ArrayBuffer>
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
FillTextureSettings
Defines fill texture behaviour
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
randomize | boolean | <optional> | true | Generates random texture size for every input |
size | Size | <optional> | image size | What piece of image to be used |
offset | Common.Point | <optional> | {x: 0, y: 0} | Beginning texture offset, when randomize is true random offset is generated. Offset should be in range [0, 1]. |
ImageDescriptor
Image descriptor
Properties:
Name | Type | Description |
---|---|---|
name | URI | Image identifier, used for serialization. When available binary content will not be serialized. URIResolver should provide binary when brush is deserialized. |
value | URI|URL|Uint8Array | Path pointing to the image or image content that will be used as a pixel source |
ParticleSettings
Defines particle behaviour
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
spacing | float | <optional> | 0.15 | Separation between particles. It should be a positive number.The value must be greater than 0. Value of 1 means that the distance between two particles will be equal the average width of the two particles. |
scattering | float | <optional> | 0 | Controls how much the particles will spread out sideways. Value of 0 means no spread out.Values of 1, means that each particle will be displaced sideways a random amount between 0% to 100% of its width. |
blendMode | Rendering.BlendMode | <optional> | SOURCE_OVER | Blend mode used when blending the strokes in the target layer |
rotationMode | Rendering.WebGL.BrushGL.RotationMode | <optional> | RANDOM | Particle rotation mode |
RotationMode
Enum used in BrushGL that describes rotation of particles
Properties:
Name | Type | Description |
---|---|---|
NONE | object | Rotation not available |
RANDOM | object | Particle is rotated randomly around its center |
TRAJECTORY | object | Particle rotates in such a way that it follows the trajectory |