Class: CanvasRendererBridge

Kekule.Render. CanvasRendererBridge

new CanvasRendererBridge()

Render bridge class of HTML5 Canvas.
Source:

Members

SHADOW_CANVAS_FIELD

Source:

Methods

(static) isSupported() → {Bool}

Check if current environment supports HTML canvas.
Source:
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
Source:
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
Source:
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
Source:
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
Source:
Returns:
Type
Bool

clearContext(context)

Clear the whole context.
Parameters:
Name Type Description
context Object
Source:

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.
Source:
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}
Source:
Returns:
Null or element drawn on context.
Type
Object

getContextDimension(context) → {Hash}

Get width and height of context.
Parameters:
Name Type Description
context Object
Source:
Returns:
{width, height}
Type
Hash

getContextElem(context)

Get context related element.
Parameters:
Name Type Description
context Object
Source:

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
Source:
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
Source:
Returns:
An object with width and height fields.
Type
Hash

releaseContext(context)

Destroy context created.
Parameters:
Name Type Description
context Object
Source:

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
Source:

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
Source:

transformContextCoordToScreen(context, coord) → {Hash}

Transform a context based coord to screen based one (usually in pixel).
Parameters:
Name Type Description
context Object
coord Hash
Source:
Returns:
Type
Hash

transformScreenCoordToContext(context, coord) → {Hash}

Transform a screen based coord to context based one.
Parameters:
Name Type Description
context Object
coord Hash
Source:
Returns:
Type
Hash