# Class: Canvas

## Kinetic. Canvas

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

  Canvas Renderer constructor

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `config` | Object | ###### Properties
  Name | Type | Description
  --- | --- | ---
  `width` | Number |
  `height` | Number |
  `pixelRatio` | Number | KineticJS 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:
    - kinetic-v5.1.10.js, line 1358

### Methods

#### getContext() → {CanvasContext}

  get canvas context

  Source:
    - kinetic-v5.1.10.js, line 1386

  ##### Returns:

  context

  Type
    CanvasContext

#### getHeight() → {Number}

  get height

  Source:
    - kinetic-v5.1.10.js, line 1451

  ##### Returns:

  height

  Type
    Number

#### getPixelRatio() → {Number}

  get pixel ratio

  Source:
    - kinetic-v5.1.10.js, line 1395

  ##### Returns:

  pixel ratio

  Type
    Number

#### getWidth() → {Number}

  get width

  Source:
    - kinetic-v5.1.10.js, line 1442

  ##### Returns:

  width

  Type
    Number

#### setHeight(height)

  set height

  ##### Parameters:

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

  Source:
    - kinetic-v5.1.10.js, line 1431

#### setPixelRatio(pixelRatio)

  get pixel ratio

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `pixelRatio` | Number | KineticJS 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:
    - kinetic-v5.1.10.js, line 1410

#### setSize(width, height)

  set size

  ##### Parameters:

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

  Source:
    - kinetic-v5.1.10.js, line 1461

#### setWidth(width)

  set width

  ##### Parameters:

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

  Source:
    - kinetic-v5.1.10.js, line 1420

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

  to data url

  ##### Parameters:

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

  Source:
    - kinetic-v5.1.10.js, line 1473

  ##### Returns:

  data url string

  Type
    String