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¶
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 )¶
@param {string|Color|Property.<string>} style
setStrokeStyle( style )¶
@param {string|Color|Property.<string>} style
setLineWidth( width )¶
@param {number} width
setLineCap( cap )¶
@param {string} cap
setLineJoin( join )¶
@param {string} join
setMiterLimit( miterLimit )¶
@param {number} miterLimit
setLineDash( dash )¶
@param {Array.<number>|null} dash
setLineDashOffset( lineDashOffset )¶
@param {number} lineDashOffset
setFont( font )¶
@param {string} font
setDirection( direction )¶
@param {string} direction
Source Code¶
See the source for CanvasContextWrapper.js in the scenery repository.