rasterizeNode¶
Under Construction
This documentation is auto-generated, and is a work in progress. Please see the source code at https://github.com/phetsims/scenery/blob/main/js/util/rasterizeNode.ts for the most up-to-date information.
Overview¶
Rasterization utilities for arbitrary Nodes.
@author Jonathan Olson <jonathan.olson@colorado.edu>
Type RasterizedOptions¶
- resolution?: number
{number} - Controls the resolution of the image relative to the local view units. For example, if our Node is ~100 view units across (in the local coordinate frame) but you want the image to actually have a ~200-pixel resolution, provide resolution:2. Defaults to 1.0 - sourceBounds?: Bounds2 | null
{Bounds2|null} - If provided, it will control the x/y/width/height of the toCanvas call. See toCanvas for details on how this controls the rasterization. This is in the "parent" coordinate frame, similar to node.bounds. Defaults to null - useTargetBounds?: boolean
{boolean} - If true, the localBounds of the result will be set in a way such that it will precisely match the visible bounds of the original Node (this). Note that antialiased content (with a much lower resolution) may somewhat spill outside these bounds if this is set to true. Usually this is fine and should be the recommended option. If sourceBounds are provided, they will restrict the used bounds (so it will just represent the bounds of the sliced part of the image). Defaults to true - wrap?: boolean
{boolean} - If true, the created Image Node gets wrapped in an extra Node so that it can be transformed independently. If there is no need to transform the resulting node, wrap:false can be passed so that no extra Node is created. Defaults to true - useCanvas?: boolean
{boolean} - If true, it will directly use the <canvas> element (only works with canvas/webgl renderers) instead of converting this into a form that can be used with any renderer. May have slightly better performance if svg/dom renderers do not need to be used. Defaults to false - nodeOptions?: NodeOptions
Options to be passed to the Node that is returned by the rasterizeNode call, this could be the direct Image or a wrapped Node, depending on the value of options.wrap. In general it is best to use this option, and only provide imageOptions for specific requirements. These options will override any imageOptions if wrap:false. Defaults to \ the empty object. - imageOptions?: ImageOptions
To be passed to the Image node created from the rasterization. See below for options that will override what is passed in. In general, it is better to use nodeOptions. These options are overridden by nodeOptions when wrap:false. Defaults to the empty object.
Source Code¶
See the source for rasterizeNode.ts in the scenery repository.