Skip to content

Pattern

Defined in: src/Pattern/Pattern.ts:20

See

Constructors

new Pattern()

new Pattern(options?): Pattern

Defined in: src/Pattern/Pattern.ts:95

Constructor

Parameters

options?

PatternOptions

Options object

Returns

Pattern

Properties

crossOrigin

crossOrigin: TCrossOrigin = ''

Defined in: src/Pattern/Pattern.ts:63

Default


excludeFromExport?

optional excludeFromExport: boolean

Defined in: src/Pattern/Pattern.ts:82

If true, this object will not be exported during the serialization of a canvas


id

readonly id: number

Defined in: src/Pattern/Pattern.ts:88

ID used for SVG export functionalities


offsetX

offsetX: number = 0

Defined in: src/Pattern/Pattern.ts:50

Pattern horizontal offset from object’s left/top corner

Default


offsetY

offsetY: number = 0

Defined in: src/Pattern/Pattern.ts:57

Pattern vertical offset from object’s left/top corner

Default


patternTransform?

optional patternTransform: TMat2D

Defined in: src/Pattern/Pattern.ts:71

transform matrix to change the pattern, imported from svgs.

Todo

verify if using the identity matrix as default makes the rest of the code more easy

Default


repeat

repeat: PatternRepeat = 'repeat'

Defined in: src/Pattern/Pattern.ts:43

Defaults


source

source: CanvasImageSource

Defined in: src/Pattern/Pattern.ts:76

The actual pixel source of the pattern


type

static type: string = 'Pattern'

Defined in: src/Pattern/Pattern.ts:21

Accessors

type

Get Signature

get type(): string

Defined in: src/Pattern/Pattern.ts:31

Legacy identifier of the class. Prefer using this.constructor.type ‘Pattern’ or utils like isPattern, or instance of to indentify a pattern in your code. Will be removed in future versiones

TODO

add sustainable warning message

Returns

string

Set Signature

set type(value): void

Defined in: src/Pattern/Pattern.ts:35

Parameters
value

string

Returns

void

Methods

isCanvasSource()

isCanvasSource(): this is { source: HTMLCanvasElement }

Defined in: src/Pattern/Pattern.ts:112

Returns

this is { source: HTMLCanvasElement }

true if source is a element


isImageSource()

isImageSource(): this is { source: HTMLImageElement }

Defined in: src/Pattern/Pattern.ts:103

Returns

this is { source: HTMLImageElement }

true if source is an element


sourceToString()

sourceToString(): string

Defined in: src/Pattern/Pattern.ts:116

Returns

string


toLive()

toLive(ctx): null | CanvasPattern

Defined in: src/Pattern/Pattern.ts:129

Returns an instance of CanvasPattern

Parameters

ctx

CanvasRenderingContext2D

Context to create pattern

Returns

null | CanvasPattern


toObject()

toObject(propertiesToInclude?): Record<string, any>

Defined in: src/Pattern/Pattern.ts:150

Returns object representation of a pattern

Parameters

propertiesToInclude?

string[] = []

Any properties that you might want to additionally include in the output

Returns

Record<string, any>

Object representation of a pattern instance


toSVG()

toSVG(__namedParameters): string

Defined in: src/Pattern/Pattern.ts:170

Returns SVG representation of a pattern

Parameters

__namedParameters

TSize

Returns

string


fromObject()

static fromObject(__namedParameters, options?): Promise<Pattern>

Defined in: src/Pattern/Pattern.ts:202

Parameters

__namedParameters

SerializedPatternOptions

options?

Abortable

Returns

Promise<Pattern>