#

API Docs for: 1.5.0
Show: Inherited Protected Private Deprecated

# CanvasRenderer Class

Defined in: `src/pixi/renderers/canvas/CanvasRenderer.js:5`
Module: PIXI

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]`

)

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:5`

#### Parameters:

- `width=800` Number

  the width of the canvas view

- `height=600` Number

  the height of the canvas view

- `[view]` HTMLCanvasElement optional

  the canvas to use as a view, optional

- `[transparent=false]` Boolean optional

  the transparency of the render view, default false

- Index
- Methods
- Properties

## Item Index

### Methods

- CanvasBuffer static
- clear
- render
- renderDisplayObject
- renderStrip
- renderStripFlat
- resize
- resize

### Properties

- CanvasMaskManager
- clearBeforeRender
- context
- height
- renderSession
- roundPixels
- transparent
- view
- width

## Methods

### `CanvasBuffer`

(

- `width`
- `height`

)
private static

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:343`

Creates a Canvas element of the given size

#### Parameters:

- `width` Number

  the width for the newly created canvas

- `height` Number

  the height for the newly created canvas

### `clear`

() private

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:364`

Clears the canvas that was created by the CanvasBuffer class

### `render`

(

- `stage`

)

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:172`

Renders the stage to its canvas view

#### Parameters:

- `stage` Stage

  the Stage element to be rendered

### `renderDisplayObject`

(

- `displayObject`
- `context`

)
private

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:235`

Renders a display object

#### Parameters:

- `displayObject` DisplayObject

  The displayObject to render

- `context` Context2D

  the context 2d method of the canvas

### `renderStrip`

(

- `strip`

)
private

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:287`

Renders a strip

#### Parameters:

- `strip` Strip

  The Strip to render

### `renderStripFlat`

(

- `strip`

)
private

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:253`

Renders a flat strip

#### Parameters:

- `strip` Strip

  The Strip to render

### `resize`

(

- `width`
- `height`

)

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:219`

Resizes the canvas view to the specified width and height

#### Parameters:

- `width` Number

  the new width of the canvas view

- `height` Number

  the new height of the canvas view

### `resize`

(

- `width`
- `height`

)
private

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:375`

Resizes the canvas that was created by the CanvasBuffer class to the specified width and height

#### Parameters:

- `width` Number

  the new width of the canvas

- `height` Number

  the new height of the canvas

## Properties

### `CanvasMaskManager`

CanvasMaskManager

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:140`

Instance of a PIXI.CanvasMaskManager, handles masking when using the canvas renderer

### `clearBeforeRender`

Boolean

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:22`

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

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:125`

The canvas 2d context that everything is drawn with

### `height`

Number

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:108`

The height of the canvas view

Default: 600

### `renderSession`

Object

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:147`

The render session is just a bunch of parameter used for rendering

### `roundPixels`

Boolean

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:34`

If true Pixi will Math.floor() x/y values when rendering, stopping pixel interpolation. Handy for crisp pixel art and speed on legacy devices.

### `transparent`

Boolean

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:44`

Whether the render view is transparent

### `view`

HTMLCanvasElement

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:117`

The canvas element that everything is drawn to

### `width`

Number

Defined in `src/pixi/renderers/canvas/CanvasRenderer.js:99`

The width of the canvas view

Default: 800