Class: RaphaelRendererBridge

Kekule.Render. RaphaelRendererBridge

new RaphaelRendererBridge()

Render bridge class of Raphael.
Source:

Methods

(static) isSupported() → {Bool}

Check if current environment supports Raphael (SVG or VML).
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) → {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.
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:

measureDrawnText(context, textElem, options) → {Hash}

Mearsure the width and height of text on context after drawing it.
Parameters:
Name Type Description
context Object
textElem Object Drawn text element on context.
options Object
Source:
Returns:
An object with width and height fields, top and left is optional.
Type
Hash

modifyDrawnTextCoord(context, textElem, newCoord)

Change text drawn on context to a new coord. Not all context can apply this action.
Parameters:
Name Type Description
context Object
textElem Object
newCoord Hash The top left coord of text box.
Source:

releaseContext(context)

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

removeDrawnElem(context, elem)

Remove an element in context.
Parameters:
Name Type Description
context Object
elem 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:

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