Skip to content

CanvasContextWrapper

Overview

Wraps the context and contains a reference to the canvas, so that we can absorb unnecessary state changes, and possibly combine certain fill operations.

TODO: performance analysis, possibly axe this and use direct modification. https://github.com/phetsims/scenery/issues/1581

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

Class CanvasContextWrapper

import { CanvasContextWrapper } from 'scenerystack/scenery';

Constructor

new CanvasContextWrapper( canvas, context )

Instance Methods

resetStyles()

Set local styles to undefined, so that they will be invalidated later @public

setDimensions( width, height )

Sets a (possibly) new width and height, and clears the canvas. @public

@param {number} width @param {number} height

setFillStyle( style )

@public

@param {string|Color|Property.<string>} style

setStrokeStyle( style )

@public

@param {string|Color|Property.<string>} style

setLineWidth( width )

@public

@param {number} width

setLineCap( cap )

@public

@param {string} cap

setLineJoin( join )

@public

@param {string} join

setMiterLimit( miterLimit )

@public

@param {number} miterLimit

setLineDash( dash )

@public

@param {Array.<number>|null} dash

setLineDashOffset( lineDashOffset )

@public

@param {number} lineDashOffset

setFont( font )

@public

@param {string} font

setDirection( direction )

@public

@param {string} direction

Source Code

See the source for CanvasContextWrapper.js in the scenery repository.