b5.Display
The Display object is a small abstraction layer around the rendering context.
Internal properties
- canvas – The HTML5 canvas object
- cache_ctx – Current cached object context
- context – The canvas context
Methods
Display(canvas) – Creates an instance of the Display object
- canvas – The HTML5 canvas that will be rendered to
getCanvasPoint(x_pos, y_pos) – Converts and x and y position to a canvas position
- x_pos – X position
- y_pos – Y position
- returns an {x, y} object containing canvas point
clear() – Clears the canvas
drawPolygon(x, y, points, fill) – Draws a polygon using current context
- x, y – Position at which to draw the polygon
- points – An array of points that represent the polygon in form of [x1,y1,x2,y2,...]
- fill – If true then the polygon will drawn filled otherwise outlined
drawLine(x1, y1, x2, y2) – Draws a line from x1, y1 to x2, y2 using current context
drawRect(x, y, w, h, fill) – Draws a rectangle using current context
- x, y – Position at which to draw the rectangle
- w – Width of the rectangle
- h – Height of the rectangle
- fill – If true then the polygon will drawn filled otherwise outlined
drawRoundRect(x, y, w, h, radius, fill) – Draws a rounded rectangle using current context
- x, y – Position at which to draw the rectangle
- w – Width of the rectangle
- h – Height of the rectangle
- radius – Corner radius
- fill – If true then the polygon will drawn filled otherwise outlined
drawArc(x, y, radius, start_angle, end_angle, fill) – Draws an arc
- x, y – Position at which to draw the arc
- radius – Radius of the arc
- start_angle – The angle at which to start drawing the arc in radians
- end_angle – The angle at which to end drawing the arc in radians
- fill – If true then the polygon will drawn filled otherwise outlined
drawAtlasImage(image, src_x, src_y, src_w, src_h, x, y, w, h) – Draws a portion of an image using current context
- image – Source image
- src_x, src_y – Top-left position of the sub section of the bitmap
- src_w, src_h – Width and height of sub section of the bitmap
- x, y – Position at which to draw the image
- w, h – Width and height of the image drawn
drawImage(image, x, y, w, h) – Draws an image using current context
- image – Source image
- x, y – Position at which to draw the image
- w, h – Width and height of the image drawn
drawText(text, x, y, filled) – Draws text using current context
- text – Text string to draw
- x, y – Position at which to draw the text
- filled – If true then the text will drawn filled otherwise outlined
setTransform(m11, m12, m21, m22, dx, dy) – Sets the current transform for current context
clipRect(x, y, w, h) – Sets the current clip rect area for current context
clipArc(x, y, radius, start, end) – Sets the current clip arc area for current context
clipPolygon(points) – Sets the current clip polygon area for current context
saveContext() – Saves the current context
restoreContext() – Restores the current context
createCache() – Creates and returns a canvas that will be used for caching
setGlobalAlpha(alpha) – Sets global alpha value for current context
setGlobalCompositeOp(op) – Sets global composite operation for current context
setShadow(x, y, colour, blur) – Sets current shadow properties for current context
setShadowOff() – Turns shadows off for current context
setFillStyle(style) – Sets the fill style for the current context
setStrokeStyle(style) – Sets the stoke style for the current context
setLineWidth(width) – Sets the line width for the current context
setFont(font) – Sets the font for the current context
setTextAlign(align) – Sets the text alignment for the current context
setTextBaseline(baseline) – Sets the text baseline for the current context
setSmoothing(enable) – Sets smoothing for the current context
setCache(cache) – Sets the current cached context
1,536 total views, 1 views today