Skip to content

Paint

Overview

Base type for gradients and patterns (and NOT the only type for fills/strokes)

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

Class Paint

import { Paint } from 'scenerystack/scenery';

Constructor

new Paint()

Instance Methods

getCanvasStyle() : string | CanvasGradient | CanvasPattern

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

setTransformMatrix( transformMatrix : Matrix3 ) : this

Sets how this paint (pattern/gradient) is transformed, compared with the local coordinate frame of where it is

NOTE: This should only be used before the pattern/gradient is ever displayed. TODO: Catch if this is violated? https://github.com/phetsims/scenery/issues/1581

NOTE: The scale should be symmetric if it will be used as a stroke. It is difficult to set a different x and y scale for canvas at the same time.

createSVGPaint( svgBlock : SVGBlock ) : SVGGradient | SVGPattern

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

toString() : string

Returns a string form of this object

Instance Properties

isPaint : boolean

Source Code

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