Skip to content

SVGBlock

Overview

Handles a visual SVG layer of drawables.

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

Class SVGBlock

import { SVGBlock } from 'scenerystack/scenery';

Constructor

new SVGBlock( display, renderer, transformRootInstance, filterRootInstance )

Instance Methods

initialize( display, renderer, transformRootInstance, filterRootInstance )

@public

@param {Display} display - the scenery Display this SVGBlock will appear in @param {number} renderer - the bitmask for the renderer, see Renderer.js @param {Instance} transformRootInstance - All transforms of this instance and its ancestors will already have been applied. This block will only be responsible for applying transforms of this instance's descendants. @param {Instance} filterRootInstance - All filters (visibility/opacity/filters) of this instance and its ancestors will already have been applied. This block will only be responsible for applying filters of this instance's descendants. @returns {FittedBlock}

onAddPaint( paint )

Callback for paintCountMap's create @private

@param {Paint} paint @returns {SVGGradient|SVGPattern}

onRemovePaint( paint, svgPaint )

Callback for paintCountMap's destroy @private

@param {Paint} paint @param {SVGGradient|SVGPattern} svgPaint

incrementPaint( paint )

Increases our reference count for the specified {Paint}. If it didn't exist before, we'll add the SVG def to the paint can be referenced by SVG id. @public

@param {Paint} paint

decrementPaint( paint )

Decreases our reference count for the specified {Paint}. If this was the last reference, we'll remove the SVG def from our SVG tree to prevent memory leaks, etc. @public

@param {Paint} paint

markDirtyGradient( gradient )

@public

@param {SVGGradient} gradient

markDirtyGroup( block )

@public

@param {Block} block

markDirtyDrawable( drawable )

@public

@param {Drawable} drawable

setSizeFullDisplay()

@public @override

setSizeFitBounds()

@public @override

update()

Updates the DOM appearance of this drawable (whether by preparing/calling draw calls, DOM element updates, etc.) @public @override

@returns {boolean} - Whether the update should continue (if false, further updates in supertype steps should not be done).

reduceReferences()

Looks to remove dirty objects that may have been disposed. See https://github.com/phetsims/energy-forms-and-changes/issues/356 @public

@public

dispose()

Releases references @public

addDrawable( drawable )

@public @override

@param {Drawable} drawable

removeDrawable( drawable )

@public @override

@param {Drawable} drawable

onIntervalChange( firstDrawable, lastDrawable )

@public @override

@param {Drawable} firstDrawable @param {Drawable} lastDrawable

toString()

Returns a string form of this object @public

@returns {string}

Source Code

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