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]
Float optionalthe width of the canvas view
-
[height=600]
Float optionalthe height of the canvas view
-
[options]
Object optionalThe optional renderer parameters
-
[view]
HTMLCanvasElement optionalthe canvas to use as a view, optional
-
[transparent=false]
Bool optionalIf the render view is transparent, default false
-
[resolution=1]
Float optionalthe resolution of the renderer retina would be 2
-
[clearBeforeRender=true]
Bool optionalThis sets if the CanvasRenderer will clear the canvas or not before the new render pass.
-
Item Index
Methods
render
-
stage
Renders the stage to its canvas view
Parameters:
-
stage
Stagethe Stage element to be rendered
resize
-
width
-
height
Resizes the canvas view to the specified width and height
Parameters:
-
width
Floatthe new width of the canvas view
-
height
Floatthe new height of the canvas view
Properties
clearBeforeRender
Bool
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 2d Context
The canvas 2d context that everything is drawn with
height
Float
The height of the canvas view
Default: 600
maskManager
CanvasMaskManager
Instance of a PIXI.CanvasMaskManager, handles masking when using the canvas renderer
refresh
Bool
Boolean flag controlling canvas refresh.
renderSession
Dynamic
The render session is just a bunch of parameter used for rendering
resolution
Float
The resolution of the canvas
Default: 1
transparent
Bool
Whether the render view is transparent
type
Int
view
CanvasElement
The canvas element that everything is drawn to
width
Float
The width of the canvas view
Default: 800