Class: Abstract3DDrawBridge

Kekule.Render. Abstract3DDrawBridge

new Abstract3DDrawBridge()

Different renderer should provide different methods to draw element on context. Those different implementations are wrapped in draw bridge classes. Concrete bridge classes do not need to deprived from this class, but they do need to implement all those essential methods. In all drawXXX methods, parameter options contains the style information to draw color and so on. It may contain the following fields: { color: String, '#rrggbb', opacity: Float, 0-1, lineWidth: Int (in drawLine method), withEndCaps: Bool (in drawCylinderEx) } In all drawXXX methods, coord are based on context (not directly on screen).
Source:

Methods

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

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 //@param {Int} contextOffsetX X coord of top-left corner of context, in px. //@param {Int} contextOffsetY Y coord of top-left corner of context, in px.
width Int Width of context, in px.
height Int Height of context, in px.
Source:
Returns:
Context used for drawing.
Type
Object

exportToDataUri(context, dataType, options) → {String}

Export drawing content to a data URL for tag to use.
Parameters:
Name Type Description
context Object
dataType String Type of image data, e.g. 'image/png'.
options Hash Export options, usually this is a number between 0 and 1 indicating image quality if the requested type is image/jpeg or image/webp.
Source:
Returns:
Type
String

getCameraProps(context) → {Hash}

Returns properties of current camera, including position(coord), fov, aspect and so on.
Parameters:
Name Type Description
context Object
Source:
Returns:
Type
Hash

getContextDimension(context) → {Hash}

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

setCameraProps(context, props)

Set properties of current camera, including position(coord), fov, aspect and so on.
Parameters:
Name Type Description
context Object
props Hash
Source:

setClearColor(context, color)

Set background color of content.
Parameters:
Name Type Description
context Object
color String Color in '#RRGGBB' mode. Null means transparent.
Source:

setContextDimension(context, width, height)

Set new width and height of context.
Parameters:
Name Type Description
context Object
width Int
height Int
Source:

transformContextCoordToScreen(context, coord) → {Hash}

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