Constructor
new ImageCanvas(widthopt, heightopt)
Name | Type | Attributes | Description |
---|---|---|---|
width | number | <optional> | Canvas width. Default 256. |
height | number | <optional> | Canvas height. Default 256. |
- Source
Methods
drawImage(img, xopt, yopt, widthopt, heightopt)
Draw an image on the canvas.
Name | Type | Attributes | Description |
---|---|---|---|
img | Image | Draw image. | |
x | number | <optional> | Left top image corner X coordinate on the canvas. |
y | number | <optional> | Left top image corner Y coordinate on the canvas. |
width | number | <optional> | Image width slice. Image width is default. |
height | number | <optional> | Image height slice. Image height is default. |
- Source
drawText(text, xopt, yopt, fontopt, coloropt)
Draw a text on the canvas.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text | string | Text. | ||
x | number | <optional> | 0 | Canvas X - coordinate. 0 - default. |
y | number | <optional> | 14 | Canvas Y - coordinate. 0 - default. |
font | string | <optional> | normal 14px Verdana | Font style. 'normal 14px Verdana' - is default. |
color | string | <optional> | black | Css font color. |
- Source
fill(color)
Fills canvas RGBA with color.
Name | Type | Description |
---|---|---|
color | string | CSS string color. |
- Source
fillColor(color)
Fill the canvas by color.
Name | Type | Description |
---|---|---|
color | string | CSS string color. |
- Source
fillEmpty()
Fills canvas RGBA with zeroes.
- Source
getCanvas() → {HTMLCanvasElement}
Returns canvas object.
- Source
- Type:
- HTMLCanvasElement
getContext() → {CanvasRenderingContext2D}
Returns canvas context pointer.
- Source
- Type:
- CanvasRenderingContext2D
getData() → {Uint8ClampedArray}
Gets canvas pixels RGBA data.
- Source
- Type:
- Uint8ClampedArray
getHeight() → {number}
Gets canvas height.
- Source
- Type:
- number
getImage() → {Image}
Converts canvas to JS image object.
- Source
- Type:
- Image
getTextWidth(text) → {number}
Get measured text width.
Name | Type | Description |
---|---|---|
text | string | Measured text. |
- Source
- Type:
- number
getWidth() → {number}
Gets canvas width.
- Source
- Type:
- number
load(url, callbackopt)
Load image to canvas.
Name | Type | Attributes | Description |
---|---|---|---|
url | string | Image url. | |
callback | function | <optional> | Image onload callback. |
- Source
openImage()
Open canvas image in the new window.
- Source
resize(width, height)
Resize canvas.
Name | Type | Description |
---|---|---|
width | number | Width. |
height | number | Height. |
- Source
setData(data)
Sets RGBA pixel data.
Name | Type | Description |
---|---|---|
data | Array.<number> | Array RGBA data. |
- Source