Class: Canvas

Konva~ Canvas

Canvas Renderer constructor. It is a wrapper around native canvas element.
Usually you don't need to use it manually.


<abstract> new Canvas(config)

Parameters:
Name Type Description
config Object
Properties
Name Type Description
width Number
height Number
pixelRatio Number
Source:
konva.js

Methods


getContext()

get canvas context

Source:
konva.js
Returns:

context

Type
CanvasContext

pixelRatio(pixelRatio)

get/set pixel ratio.
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 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.

Parameters:
Name Type Description
pixelRatio Number
Source:
konva.js
Returns:
Type
Number
Example
// get
var pixelRatio = layer.getCanvas.pixelRatio();

// set
layer.getCanvas().pixelRatio(3);

toDataURL(mimeType, quality)

to data url

Parameters:
Name Type Description
mimeType String
quality Number

between 0 and 1 for jpg mime types

Source:
konva.js
Returns:

data url string

Type
String