Namespace R.util.RenderUtil
A static class of rendering utilities. Most of the methods are intended
for bitmap contexts, such as canvas, but may apply to others. The methods
have been designed with canvas in mind.
Defined in: renderutil.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
blur(renderContext, passes)
Blur the contents of the renderContext using the number of passes specified.
|
|
extractDataURL(image, cropRect, contextType)
Extract the image data URL from the provided image.
|
|
extractImageData(image, cropRect, contextType)
Extract the image data from the provided image.
|
|
getMaskImage(image, cropRect, contextType)
Get a mask for the provided image.
|
|
getTempContext(type, width, height)
Get a temporary context to render into.
|
|
renderComponentToImage(contextType, renderComponent, width, height, time, offset)
Perform a single execution of a rendering component.
|
|
screenShot(renderContext, cropRect)
Takes a screen shot of the context provided, optionally cropped to specific dimensions.
|
Method Detail
blur(renderContext, passes)
Blur the contents of the renderContext using the number of passes specified.
The blur operation is fairly quick and is an approximation of a blur, not an actual
blur filter. However, this method is slow and shouldn't be called per frame due to
passing the render context on the stack.
- Parameters:
- renderContext
- {R.rendercontexts.RenderContext2D} The context to blur
- passes Optional
- {Number} Optional number of passes to apply (default: 1)
{String}
extractDataURL(image, cropRect, contextType)
Extract the image data URL from the provided image. The image can either be an HTML <img> element,
or it can be another render context. This method currently only works with the canvas context.
- Parameters:
- image
- {Object} Image or context
- cropRect Optional
- {R.math.Rectangle2D} A rectangle to crop to, or
null
to use the entire image - contextType Optional
- {R.rendercontexts.RenderContext2D} Optional render context class, or
null
to assume a canvas context.
- Returns:
- {String} A data URL for the extracted image
{Object}
extractImageData(image, cropRect, contextType)
Extract the image data from the provided image. The image can either be an HTML <img> element,
or it can be another render context. This method currently only works with the canvas context.
- Parameters:
- image
- {Object} Image or context
- cropRect Optional
- {R.math.Rectangle2D} A rectangle to crop to, or
null
to use the entire image - contextType Optional
- {R.rendercontexts.RenderContext2D} Optional render context class, or
null
to assume a canvas context.
- Returns:
- {Object} Image data object with "width", "height", and an Array of each pixel, represented as RGBA data where each element is represented by an integer 0-255.
{String}
getMaskImage(image, cropRect, contextType)
Get a mask for the provided image. The mask is a simple pixel, no-pixel image which
exactly mimics the provided image.
- Parameters:
- image
- {Object} Image or context
- cropRect Optional
- {R.math.Rectangle2D} A rectangle to crop to, or
null
to use the entire image - contextType Optional
- {R.rendercontexts.RenderContext2D} Optional render context class, or
null
to assume a canvas context.
- Returns:
- {String} A data URL for the image mask
{R.rendercontexts.RenderContext2D}
getTempContext(type, width, height)
Get a temporary context to render into. Only one context will ever be created for the type
specified, and cached for repeated use. It will be cleaned up when the engine is shut down.
- Parameters:
- type
- {R.rendercontexts.RenderContext2D} The context class to mimic
- width
- {Number} The width of the temporary context
- height
- {Number} The height of the temporary context
- Returns:
- {R.rendercontexts.RenderContext2D}
{String}
renderComponentToImage(contextType, renderComponent, width, height, time, offset)
Perform a single execution of a rendering component.
- Parameters:
- contextType
- {R.rendercontexts.RenderContext2D} The type of context to render to
- renderComponent
- {R.components.Render} The component to render
- width
- {Number} The width of the temporary context
- height
- {Number} The height of the temporary context
- time
- {Number} The time in milliseconds, or
null
to use the current engine time - offset
- {R.math.Point2D} The offset for the rendering position
- Returns:
- {String} The data URL of the rendered image
{String}
screenShot(renderContext, cropRect)
Takes a screen shot of the context provided, optionally cropped to specific dimensions.
- Parameters:
- renderContext
- {R.rendercontexts.RenderContext2D} The context to get a screenshot of
- cropRect Optional
- {R.math.Rectangle2D} Optional rectangle to crop to, or
null
for the entire context.
- Returns:
- {String} The data URL of the screen shot