Skip to main content

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:
NameTypeDescription
nameURIBrush identifier
shapeImageSRC|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
fillImageSRC|Rendering.WebGL.BrushGL.ImageDescriptorValid image src or descriptor that will be used as a pixel source
particleSettingsRendering.WebGL.BrushGL.ParticleSettingsParticle configuration
fillTextureSettingsRendering.WebGL.BrushGL.FillTextureSettingsFill texture options
Properties:
NameTypeAttributesDefaultDescription
encodingSerialization.TypedArrayCodec.Encoding<optional>AUTOApplicable for JSON serialization, configures shape and fill serialization type

Since:

  • 1.0

Methods

(async) configure(ctx) → {Promise}

Loads shape and fill pixels

Parameters:
NameTypeDescription
ctxWebGLRenderingContext|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:
NameTypeDescription
dataJSONPolygon brush data
Returns:

Brush2D instance

Type

Rendering.2D.Brush2D

Type Definitions

FillTextureSettings

Defines fill texture behaviour

Properties:
NameTypeAttributesDefaultDescription
randomizeboolean<optional>trueGenerates random texture size for every input
sizeSize<optional>image sizeWhat piece of image to be used
offsetCommon.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:
NameTypeDescription
nameURIImage identifier, used for serialization. When available binary content will not be serialized. URIResolver should provide binary when brush is deserialized.
valueURI|URL|Uint8ArrayPath pointing to the image or image content that will be used as a pixel source

ParticleSettings

Defines particle behaviour

Properties:
NameTypeAttributesDefaultDescription
spacingfloat<optional>0.15Separation 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.
scatteringfloat<optional>0Controls 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.
blendModeRendering.BlendMode<optional>SOURCE_OVERBlend mode used when blending the strokes in the target layer
rotationModeRendering.WebGL.BrushGL.RotationMode<optional>RANDOMParticle rotation mode

RotationMode

Enum used in BrushGL that describes rotation of particles

Properties:
NameTypeDescription
NONEobjectRotation not available
RANDOMobjectParticle is rotated randomly around its center
TRAJECTORYobjectParticle rotates in such a way that it follows the trajectory

Home