new UBCanvas(width, height, fillColoropt)
Create new Canvas and fill it by provided color.
Arguments:
-
width
(Number)
-
height
(Number)
-
[fillColor=0]
(Number|Object)
 Either a result of UBCanvas#createColor or object {r: Number, g: number, b: Number}
Members
FontStyles: Object
static
Possible font style for setFont
TextFormats: Object
static
Possible text drawing options for drawText
Methods
createNew(width, height, fillColoropt)
Set Canvas width and height in pixels & fill it by provided color.
In case color is 0 or omitted, fill with white.
It is mandatory to call createNew before any other Canvas operation.
Arguments:
-
width
(Number)
-
height
(Number)
-
[fillColor=0]
(Number|Object)
 Either a result of UBCanvas#createColor or object {r: Number, g: number, b: Number}
setFont(fontName, fontColor, fontSize, fontStylesopt)
Set a font for future UBCanvas#drawText operations
Arguments:
-
fontName
(String)
 Name of font as it displayed in the OS
-
fontColor
(Number|Object)
 Either a result of UBCanvas#createColor or object {r: Number, g: number, b: Number}
-
fontSize
(Number)
 Font size in punkts
-
[fontStyles]
(Array:.<UBCanvas.FontStyle:>)
 Default is []
drawText(x, y, text, clipWidth, clipHeight, drawOptionsopt)
Draw a text on the Canvas using previously defined Font
Arguments:
-
x
(Number)
-
y
(Number)
-
text
(String)
-
clipWidth
(Number)
-
clipHeight
(Number)
-
[drawOptions]
(Array:.<UBCanvas.TextFormat:>)
 return {{width: Number, height: Number}} text rectangle
measureText(text) → Object
Arguments:
-
text
(String)
drawImage(x, y, image, widthopt, heightopt, imageTypeopt)
Arguments:
-
x
(Number)
-
y
(Number)
-
image
(ArrayBuffer)
-
[width=0]
(Number)
 0 - image width or calculated proportionally
-
[height=0]
(Number)
 0 - image height or calculated proportionally
-
[imageType=UBCanvas.imageTypes.PNG]
(Number)
 UBCanvas.imageTypes (0 - BMP, 1 - PNG, 2 - JPEG, 3 - GIF)
saveToFile(fileName)
Save Canvas content to file in PNG format
Arguments:
-
fileName
(String)
getContent()
Get Canvas content. See UBReader#read
freeNative()
Release all internal resources.
Do not use this object after call to freeNative!
createNew(width, height, fillColoropt)
Set Canvas width and height in pixels & fill it by provided color.
In case color is 0 or omitted, fill with white.
It is mandatory to call createNew before any other Canvas operation.
Arguments:
-
width
(Number)
-
height
(Number)
-
[fillColor=0]
(Number|Object)
 Either a result of UBCanvas#createColor or object {r: Number, g: number, b: Number}
setFont(fontName, fontColor, fontSize, fontStylesopt)
Set a font for future UBCanvas#drawText operations
Arguments:
-
fontName
(String)
 Name of font as it displayed in the OS -
fontColor
(Number|Object)
 Either a result of UBCanvas#createColor or object {r: Number, g: number, b: Number} -
fontSize
(Number)
 Font size in punkts -
[fontStyles]
(Array:.<UBCanvas.FontStyle:>)
 Default is []
drawText(x, y, text, clipWidth, clipHeight, drawOptionsopt)
Draw a text on the Canvas using previously defined Font
Arguments:
-
x
(Number)
-
y
(Number)
-
text
(String)
-
clipWidth
(Number)
-
clipHeight
(Number)
-
[drawOptions]
(Array:.<UBCanvas.TextFormat:>)
 return {{width: Number, height: Number}} text rectangle
measureText(text) → Object
Arguments:
-
text
(String)
drawImage(x, y, image, widthopt, heightopt, imageTypeopt)
Arguments:
-
x
(Number)
-
y
(Number)
-
image
(ArrayBuffer)
-
[width=0]
(Number)
 0 - image width or calculated proportionally -
[height=0]
(Number)
 0 - image height or calculated proportionally -
[imageType=UBCanvas.imageTypes.PNG]
(Number)
 UBCanvas.imageTypes (0 - BMP, 1 - PNG, 2 - JPEG, 3 - GIF)
saveToFile(fileName)
Save Canvas content to file in PNG format
Arguments:
-
fileName
(String)
getContent()
Get Canvas content. See
UBReader#read
freeNative()
Release all internal resources.
Do not use this object after call to freeNative!