<virtual> new Canvas(config)
Canvas Renderer constructor
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
Properties
|
- Source:
Methods
-
getContext() → {CanvasContext}
-
get canvas context
- Source:
Returns:
context
- Type
- CanvasContext
-
getHeight() → {Number}
-
get height
- Source:
Returns:
height
- Type
- Number
-
getPixelRatio() → {Number}
-
get pixel ratio
- Source:
Returns:
pixel ratio
- Type
- Number
-
getWidth() → {Number}
-
get width
- Source:
Returns:
width
- Type
- Number
-
setHeight(height)
-
set height
Parameters:
Name Type Description height
Number - Source:
-
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:
-
setSize(width, height)
-
set size
Parameters:
Name Type Description width
Number height
Number - Source:
-
setWidth(width)
-
set width
Parameters:
Name Type Description width
Number - Source:
-
toDataURL(mimeType, quality) → {String}
-
to data url
Parameters:
Name Type Description mimeType
String quality
Number between 0 and 1 for jpg mime types
- Source:
Returns:
data url string
- Type
- String