Class: PatternStyle

PatternStyle(source)

new PatternStyle(source)

Pattern style represents an opaque object describing a pattern, based on an image, a canvas, or a video. The get method returns a CanvasPattern object https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern created by the context.createPattern() method.
Parameters:
Name Type Description
source CanvasImageSource Source element of the pattern.
Source:

Extends

Members

cache :string|CanvasGradient|CanvasPattern

Cached style object pre-generated from previous calls. To avoid regenerating the same style object every cycle. Inherited classes should write their own get method that returns the style object and stores it in this property.
Type:
  • string | CanvasGradient | CanvasPattern
Overrides:
Source:

matrix :Matrix

Transformation matrix applied to the pattern. The transformation allows to move, rotate and scale the pattern freely
Type:
Source:

needsUpdate :boolean

Indicates if the style object needs to be updated, should be used after applying changed to the style in order to generate a new object. Inherited classes should implement this functionality.
Type:
  • boolean
Overrides:
Source:

repetition :string

Repetition indicates how the pattern image should be repeated. Possible values are "repeat", "repeat-x", "repeat-y" or "no-repeat". More information about this attribute here https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/createPattern.
Type:
  • string
Source:

source :CanvasImageSource

Source of the pattern style. Can be a image, video or another canvas element By default a empty image element is created.
Type:
  • CanvasImageSource
Source:

Methods

get(context) → {string|CanvasGradient|CanvasPattern}

Get generated style object from style data and the drawing context.
Parameters:
Name Type Description
context CanvasRenderingContext2D Context being used to draw the object.
Overrides:
Source:
Returns:
Return the canvas style object generated.
Type
string | CanvasGradient | CanvasPattern

parse(data)

Parse the style attributes from JSON object data created with the serialize() method.
Parameters:
Name Type Description
data Object Serialized style data.
Overrides:
Source:

serialize() → {Object}

Serialize the style to JSON object, called by the objects using these styles.
Overrides:
Source:
Returns:
Serialized style data.
Type
Object

setTransform(transform)

Applies an 2x3 transformation matrix representing a linear transform to the pattern.
Parameters:
Name Type Description
transform Array.<number> 2x3 Transformation matrix.
Source: