Skip to content

Pattern

Overview

A pattern that will deliver a fill or stroke that will repeat an image in both directions (x and y).

TODO: future support for repeat-x, repeat-y or no-repeat (needs SVG support) https://github.com/phetsims/scenery/issues/1581 TODO: support scene or other various content (SVG is flexible, can backport to canvas)

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class Pattern

import { Pattern } from 'scenerystack/scenery';

Constructor

new Pattern( image : HTMLImageElement )

Instance Methods

getCanvasStyle() : CanvasPattern

Returns an object that can be passed to a Canvas context's fillStyle or strokeStyle.

createSVGPaint( svgBlock : SVGBlock ) : SVGPattern

Creates an SVG paint object for creating/updating the SVG equivalent definition.

toString() : string

Returns a string form of this object

Instance Properties

image : HTMLImageElement

canvasPattern : CanvasPattern

isPattern : boolean

Source Code

See the source for Pattern.ts in the scenery repository.