new ImageCanvas(width, height)
Name | Type | Description |
---|---|---|
width |
number | optional Canvas width. Default 256. |
height |
number | optional Canvas height. Default 256. |
Members
Methods
-
drawImage(img, x, y, width, height)
-
Draw an image on the canvas.
Name Type 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. -
drawText(text, x, y, font, color)
-
Draw a text on the canvas.
Name Type Description text
string Text. x
number optional Canvas X - coordinate. 0 - default. y
number optional Canvas Y - coordinate. 0 - default. font
string optional Font style. 'normal 14px Verdana' - is default. color
string optional Css font color. -
fillColor(color)
-
Fill the canvas by color.
Name Type Description color
string CSS string color. -
fillEmpty()
-
Fills canvas RGBA with zeroes.
-
getCanvas(){Object}
-
Returns canvas object.
Returns:
Type Description Object -
getContext(){Object}
-
Returns canvas context pointer.
Returns:
Type Description Object -
getData(){Array.<number>}
-
Gets canvas pixels RGBA data.
Returns:
Type Description Array.<number> -
getHeight(){number}
-
Gets canvas height.
Returns:
Type Description number -
getImage(){Image}
-
Converts canvas to JS image object.
Returns:
Type Description Image -
getTextWidth(text){number}
-
Get measured text width.
Name Type Description text
string Measured text. Returns:
Type Description number -
getWidth(){number}
-
Gets canvas width.
Returns:
Type Description number -
load(url)
-
Load image to canvas.
Name Type Description url
string Image url. -
openImage()
-
Open canvas image in the new window.
-
resize(width, height)
-
Resize canvas.
Name Type Description width
number Width. height
number Height. -
setData(data)
-
Sets RGBA pixel data.
Name Type Description data
Array.<number> Array RGBA data.