# Class: Canvas

## Konva. Canvas

#### <virtual> new Canvas(config)

  Canvas Renderer constructor

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `config` | Object | ###### Properties
  Name | Type | Description
  --- | --- | ---
  `width` | Number |
  `height` | Number |
  `pixelRatio` | Number | KonvaJS automatically handles pixel ratio adjustments in order to render crisp drawings on all devices. Most desktops, low end tablets, and low end phones, have device pixel ratios of 1. Some high end tablets and phones, like iPhones and iPads (not the mini) have a device pixel ratio of 2. Some Macbook Pros, and iMacs also have a device pixel ratio of 2. Some high end Android devices have pixel ratios of 2 or 3. Some browsers like Firefox allow you to configure the pixel ratio of the viewport. Unless otherwise specified, the pixel ratio will be defaulted to the actual device pixel ratio. You can override the device pixel ratio for special situations, or, if you don't want the pixel ratio to be taken into account, you can set it to 1.

  Source:
    - konva-v5.2.0.js, line 1365

### Methods

#### getContext() → {CanvasContext}

  get canvas context

  Source:
    - konva-v5.2.0.js, line 1393

  ##### Returns:

  context

  Type
    CanvasContext

#### getHeight() → {Number}

  get height

  Source:
    - konva-v5.2.0.js, line 1458

  ##### Returns:

  height

  Type
    Number

#### getPixelRatio() → {Number}

  get pixel ratio

  Source:
    - konva-v5.2.0.js, line 1402

  ##### Returns:

  pixel ratio

  Type
    Number

#### getWidth() → {Number}

  get width

  Source:
    - konva-v5.2.0.js, line 1449

  ##### Returns:

  width

  Type
    Number

#### setHeight(height)

  set height

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `height` | Number |

  Source:
    - konva-v5.2.0.js, line 1438

#### setPixelRatio(pixelRatio)

  get pixel ratio

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pixelRatio` | Number | KonvaJS automatically handles pixel ratio adustments in order to render crisp drawings on all devices. Most desktops, low end tablets, and low end phones, have device pixel ratios of 1. Some high end tablets and phones, like iPhones and iPads (not the mini) have a device pixel ratio of 2. Some Macbook Pros, and iMacs also have a device pixel ratio of 2. Some high end Android devices have pixel ratios of 2 or 3. Some browsers like Firefox allow you to configure the pixel ratio of the viewport. Unless otherwise specificed, the pixel ratio will be defaulted to the actual device pixel ratio. You can override the device pixel ratio for special situations, or, if you don't want the pixel ratio to be taken into account, you can set it to 1.

  Source:
    - konva-v5.2.0.js, line 1417

#### setSize(width, height)

  set size

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `width` | Number |
  `height` | Number |

  Source:
    - konva-v5.2.0.js, line 1468

#### setWidth(width)

  set width

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `width` | Number |

  Source:
    - konva-v5.2.0.js, line 1427

#### toDataURL(mimeType, quality) → {String}

  to data url

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `mimeType` | String |
  `quality` | Number | between 0 and 1 for jpg mime types

  Source:
    - konva-v5.2.0.js, line 1480

  ##### Returns:

  data url string

  Type
    String