new CanvasRendererBridge()
Render bridge class of HTML5 Canvas.
Members
-
SHADOW_CANVAS_FIELD
Methods
-
(static) isSupported() → {Bool}
-
Check if current environment supports HTML canvas.
Returns:
- Type
- Bool
-
canMeasureDrawnText(context) → {Bool}
-
Indicate whether this bridge and context can measure text dimension before drawing it. Raphael is a typical environment of this type. Such a bridge must also has the ability to modify text pos after drawn.
Parameters:
Name Type Description context
Object Returns:
- Type
- Bool
-
canMeasureText(context) → {Bool}
-
Indicate whether this bridge and context can measure text dimension before drawing it. HTML Canvas is a typical environment of this type.
Parameters:
Name Type Description context
Object Returns:
- Type
- Bool
-
canModifyGraphic(context) → {Bool}
-
Indicate whether this bridge and context can change glyph content or position after drawing it. Raphael is a typical environment of this type while canvas should returns false.
Parameters:
Name Type Description context
Object Returns:
- Type
- Bool
-
canModifyText(context) → {Bool}
-
Indicate whether this bridge and context can change text content or position after drawing it. Raphael is a typical environment of this type.
Parameters:
Name Type Description context
Object Returns:
- Type
- Bool
-
clearContext(context)
-
Clear the whole context.
Parameters:
Name Type Description context
Object -
createContext(parentElem, width, height, doubleBuffered) → {Object}
-
Create a context element for drawing.
Parameters:
Name Type Description parentElem
Element width
Int Width of context, in px. height
Int Height of context, in px. doubleBuffered
Bool Whether use double buffer to make smooth drawing. Returns:
Context used for drawing.- Type
- Object
-
drawText(context, coord, text, options) → {Object}
-
Draw a plain text on context.
Parameters:
Name Type Description context
Object coord
Object The top left coord to draw text. text
Object options
Object Draw options, may contain the following fields: {fontSize, fontFamily} Returns:
Null or element drawn on context.- Type
- Object
-
getContextDimension(context) → {Hash}
-
Get width and height of context.
Parameters:
Name Type Description context
Object Returns:
{width, height}- Type
- Hash
-
getContextElem(context)
-
Get context related element.
Parameters:
Name Type Description context
Object -
getOperatingContext(context) → {Object}
-
Returns a context that need to be drawn immediately. In normal state, this function just returns the canvas itself. In double buffered mode, this function will returns the shadow canvas context.
Parameters:
Name Type Description context
Object Returns:
- Type
- Object
-
measureText(context, text, options) → {Hash}
-
Mearsure the width and height of text on context before drawing it.
Parameters:
Name Type Description context
Object text
Object options
Object Returns:
An object with width and height fields.- Type
- Hash
-
releaseContext(context)
-
Destroy context created.
Parameters:
Name Type Description context
Object -
setContextDimension(context, width, height)
-
Set new width and height of context. Note in canvas, the content should be redrawn after resizing.
Parameters:
Name Type Description context
Object width
Int height
Int -
setContextViewBox(context, x, y, w, h, changeDimension)
-
Set the view box of context. This method will also change context dimension to w/h if param changeDimension is not false.
Parameters:
Name Type Description context
Object x
Int Top left x coord. y
Int Top left y coord. w
Int Width. h
Int Height. changeDimension
Bool -
transformContextCoordToScreen(context, coord) → {Hash}
-
Transform a context based coord to screen based one (usually in pixel).
Parameters:
Name Type Description context
Object coord
Hash Returns:
- Type
- Hash
-
transformScreenCoordToContext(context, coord) → {Hash}
-
Transform a screen based coord to context based one.
Parameters:
Name Type Description context
Object coord
Hash Returns:
- Type
- Hash