Class: Pattern
Defined in: pattern.ts:53
Repeated image usable as fill or stroke
Constructors
Constructor
new Pattern(source, options?): Pattern;Defined in: pattern.ts:68
Pattern constructor
Parameters
| Parameter | Type | Description |
|---|---|---|
source | PatternSource | Source of the pattern |
options? | Partial<PatternOptions> | Some options |
Returns
Pattern
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
options | PatternOptions | Set of options | pattern.ts:59 |
Accessors
height
Get Signature
get height(): number;Defined in: pattern.ts:130
Height of the source
Returns
number
source
Get Signature
get source(): HTMLCanvasElement | HTMLImageElement | null;Defined in: pattern.ts:79
Drawable source of the pattern
Returns
HTMLCanvasElement | HTMLImageElement | null
Set Signature
set source(newSource): void;Defined in: pattern.ts:95
Change the source of the pattern
Parameters
| Parameter | Type | Description |
|---|---|---|
newSource | PatternSource | New source for the pattern |
Returns
void
width
Get Signature
get width(): number;Defined in: pattern.ts:123
Width of the source
Returns
number
className
Get Signature
get static className(): "Pattern";Defined in: pattern.ts:54
Returns
"Pattern"
defaultOptions
Get Signature
get static defaultOptions(): PatternOptions;Defined in: pattern.ts:184
Default options for this class
Returns
repetition
Get Signature
get static repetition(): object;Defined in: pattern.ts:195
Repetition rules
Returns
none
readonly none: "no-repeat" = "no-repeat";Don't repeat
repeat
readonly repeat: "repeat" = "repeat";Repeat in both directions
x
readonly x: "repeat-x" = "repeat-x";Repeat only horizontally
y
readonly y: "repeat-y" = "repeat-y";Repeat only vertically
Methods
toJSON()
toJSON(): PatternJSON;Defined in: pattern.ts:157
Return a json ready object (only works with image sources)
Returns
toString()
toString(ctx): string | CanvasPattern;Defined in: pattern.ts:138
Return a canvas pattern (or a transparent color when not ready)
Parameters
| Parameter | Type | Description |
|---|---|---|
ctx | CanvasRenderingContext2D | Drawing context |
Returns
string | CanvasPattern
from()
static from(definition): Pattern;Defined in: pattern.ts:177
Return an instance from a generic object
Parameters
| Parameter | Type | Description |
|---|---|---|
definition | Omit<PatternJSON, "constructor"> | Pattern definition |
Returns
Pattern
