CanvasRenderer Class
The CanvasRenderer draws the Stage and all its content onto a 2d canvas. This renderer should be used for browsers that do not support webGL. Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :)
Constructor
CanvasRenderer
-
[width=800]
-
[height=600]
-
[options]
Parameters:
-
[width=800]
Number optionalthe width of the canvas view
-
[height=600]
Number optionalthe height of the canvas view
-
[options]
Object optionalThe optional renderer parameters
-
[view]
HTMLCanvasElement optionalthe canvas to use as a view, optional
-
[transparent=false]
Boolean optionalIf the render view is transparent, default false
-
[autoResize=false]
Boolean optionalIf the render view is automatically resized, default false
-
[resolution=1]
Number optionalthe resolution of the renderer retina would be 2
-
[clearBeforeRender=true]
Boolean optionalThis sets if the CanvasRenderer will clear the canvas or not before the new render pass.
-
Item Index
Methods
destroy
-
[removeView=true]
Removes everything from the renderer and optionally removes the Canvas DOM element.
Parameters:
-
[removeView=true]
Boolean optionalRemoves the Canvas element from the DOM.
mapBlendModes
()
private
Maps Pixi blend modes to canvas blend modes.
render
-
stage
Renders the Stage to this canvas view
Parameters:
-
stage
Stagethe Stage element to be rendered
renderDisplayObject
-
displayObject
-
context
Renders a display object
Parameters:
-
displayObject
DisplayObjectThe displayObject to render
-
context
CanvasRenderingContext2Dthe context 2d method of the canvas
resize
-
width
-
height
Resizes the canvas view to the specified width and height
Parameters:
-
width
Numberthe new width of the canvas view
-
height
Numberthe new height of the canvas view
Properties
autoResize
Boolean
Whether the render view should be resized automatically
CanvasMaskManager
CanvasMaskManager
Instance of a PIXI.CanvasMaskManager, handles masking when using the canvas renderer
clearBeforeRender
Boolean
This sets if the CanvasRenderer will clear the canvas or not before the new render pass. If the Stage is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color. If the Stage is transparent Pixi will use clearRect to clear the canvas every frame. Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set.
context
CanvasRenderingContext2D
The canvas 2d context that everything is drawn with
count
Number
Internal var.
height
Number
The height of the canvas view
Default: 600
refresh
Boolean
Boolean flag controlling canvas refresh.
renderSession
Object
The render session is just a bunch of parameter used for rendering
resolution
Number
The resolution of the canvas.
transparent
Boolean
Whether the render view is transparent
type
Number
The renderer type.
view
HTMLCanvasElement
The canvas element that everything is drawn to.
width
Number
The width of the canvas view
Default: 800