#

API Docs for: 2.0.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. Don't forget to add the CanvasRenderer.view to your DOM or you will not see anything :)

## Constructor

### `CanvasRenderer`

(

- `[width=800]`
- `[height=600]`
- `[options]`

)

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

#### Parameters:

- `[width=800]` Number optional

  the width of the canvas view

- `[height=600]` Number optional

  the height of the canvas view

- `[options]` Object optional

  The optional renderer parameters

  - `[view]` HTMLCanvasElement optional

    the canvas to use as a view, optional

  - `[transparent=false]` Boolean optional

    If the render view is transparent, default false

  - `[resolution=1]` Number optional

    the resolution of the renderer retina would be 2

  - `[clearBeforeRender=true]` Boolean optional

    This sets if the CanvasRenderer will clear the canvas or not before the new render pass.

- Index
- Methods
- Properties

## Item Index

### Methods

- mapBlendModes
- render
- renderDisplayObject
- resize

### Properties

- CanvasMaskManager
- clearBeforeRender
- context
- count
- height
- refresh
- renderSession
- resolution
- transparent
- type
- view
- width

## Methods

### `mapBlendModes`

() private

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

Maps Pixi blend modes to canvas blend modes.

### `render`

(

- `stage`

)

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

Renders the Stage to this canvas view

#### Parameters:

- `stage` Stage

  the Stage element to be rendered

### `renderDisplayObject`

(

- `displayObject`
- `context`

)
private

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

Renders a display object

#### Parameters:

- `displayObject` DisplayObject

  The displayObject to render

- `context` CanvasRenderingContext2D

  the context 2d method of the canvas

### `resize`

(

- `width`
- `height`

)

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

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

## Properties

### `CanvasMaskManager`

CanvasMaskManager

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

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

### `clearBeforeRender`

Boolean

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

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

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

The canvas 2d context that everything is drawn with

### `count`

Number

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

Internal var.

### `height`

Number

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

The height of the canvas view

Default: 600

### `refresh`

Boolean

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

Boolean flag controlling canvas refresh.

### `renderSession`

Object

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

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

### `resolution`

Number

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

The resolution of the canvas.

### `transparent`

Boolean

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

Whether the render view is transparent

### `type`

Number

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

The renderer type.

### `view`

HTMLCanvasElement

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

The canvas element that everything is drawn to.

### `width`

Number

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

The width of the canvas view

Default: 800