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. Dont forget to add the view to your DOM or you will not see anything :)
Constructor
CanvasRenderer
-
width=800
-
height=600
-
[view]
-
[transparent=false]
Parameters:
-
width=800
Numberthe width of the canvas view
-
height=600
Numberthe height of the canvas view
-
[view]
HTMLCanvasElement optionalthe canvas to use as a view, optional
-
[transparent=false]
Boolean optionalthe transparency of the render view, default false
Item Index
Methods
Methods
CanvasBuffer
-
width
-
height
Creates a Canvas element of the given size
Parameters:
-
width
Numberthe width for the newly created canvas
-
height
Numberthe height for the newly created canvas
clear
()
private
Clears the canvas that was created by the CanvasBuffer class
render
-
stage
Renders the stage to its canvas view
Parameters:
-
stage
Stagethe Stage element to be rendered
renderDisplayObject
-
displayObject
-
context
Renders a display object
Parameters:
-
displayObject
DisplayObjectThe displayObject to render
-
context
Context2Dthe 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
resize
-
width
-
height
Resizes the canvas that was created by the CanvasBuffer class to the specified width and height
Parameters:
-
width
Numberthe new width of the canvas
-
height
Numberthe new height of the canvas
Properties
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
HTMLCanvasElement 2d Context
The canvas 2d context that everything is drawn with
height
Number
The height of the canvas view
Default: 600
renderSession
Object
The render session is just a bunch of parameter used for rendering
transparent
Boolean
Whether the render view is transparent
view
HTMLCanvasElement
The canvas element that everything is drawn to
width
Number
The width of the canvas view
Default: 800