Hemi JavaScript Framework

Hemi.graphics.canvas

Description

The Canvas class provides a shape management layer for browsers that support Canvas, including a temporary drawing layer and event to shape coordination.

Class Index

static Hemi.graphics.canvas.Canvas

version 3.1.0

Static initializer for CanvasInstance objects.

Index

Method Index

Methods

newInstance

Creates a new instance of the Hemi Graphics Canvas class.

Syntax

oCanvas = newInstance( o )

Parameters

Returns

oCanvas as CanvasInstance: A new instance of the Canvas class.

Hemi.graphics.canvas.CanvasInstance

version 3.1.0

The Canvas Graphics class provides a number of utitilies and helper methods for working with Canvas elements, and instrumenting and tracking objects created for the Canvas.

Index

Object Index

Property Index

Method Index

Objects

Shape

Object that describes a shape that can be rendered to the Canvas.

Properties

Properties

properties.CurrentShape

The shape at the MouseTrackLeft and MouseTrackTop location where the mousedown event fired.

Syntax

Shape = object.properties.CurrentShape

properties.MouseDropShape

The shape at the current MouseTrackLeft and MouseTrackTop location.

Syntax

Shape = object.properties.MouseDropShape

properties.MouseOffsetX

The left offset of the mouse position from the shape edge.

Syntax

int = object.properties.MouseOffsetX

properties.MouseOffsetY

The top offset of the mouse position from the shape edge.

Syntax

int = object.properties.MouseOffsetY

properties.MouseTrackChoose

Bit indicating whether the mousedown event captured a shape.

Syntax

boolean = object.properties.MouseTrackChoose

properties.MouseTrackDown

Bit indicating whether the mousedown event is in effect.

Syntax

boolean = object.properties.MouseTrackDown

properties.MouseTrackLeft

The left axis of the mouse in the canvas.

Syntax

int = object.properties.MouseTrackLeft

properties.MouseTrackTop

The top axis of the mouse in the canvas.

Syntax

int = object.properties.MouseTrackTop

Methods

_handle_canvas_mouse

Routes mouse events.

Syntax

void _handle_canvas_mouse( e )

Parameters

AddShapeDecorator

Adds a ShapeDecorator to the canvas.

Syntax

void AddShapeDecorator( )

Clear

Clears the Canvas and Temporary Canvas shapes and drawings.

Syntax

void Clear( )

ClearCanvas

Clears the Canvas shapes and drawings.

Syntax

void ClearCanvas( )

ClearTempCanvas

Clears the Temporary Canvas shapes and drawings.

Syntax

void ClearTempCanvas( )

ConnectShapes

Draws a connection between the two shapes.

Syntax

void ConnectShapes( oShape, oShape, sType )

Parameters

dispatch_decorators

Dispatches the specified event to specified decorators.

Syntax

void dispatch_decorators( e )

Parameters

Draw

Draws the specified shape onto the temporary canvas.

Syntax

void Draw( oShape, bStroke, bFix )

Parameters

DrawArc

Draws an arc shape.

Syntax

void DrawArc( oShape )

Parameters

DrawEllipse

Draws an ellipse shape. This function is based on the CanvasPaint paint.js implementation.

Syntax

void DrawEllipse( oShape )

Parameters

DrawRect

Draws a rectangular shape.

Syntax

void DrawRect( oShape )

Parameters

DrawRoundedRect

Draws a rounded rectangular shape. This function is based on the CanvasPaint paint.js implementation.

Syntax

void DrawRoundedRect( oShape )

Parameters

DrawText

Draws a text shape. If the measureText method is not implemented, a positioned HTML element is used to supply the text.

Syntax

void DrawText( oShape )

Parameters

FindShapeAt

Finds a shape at the specified coordinates.

Syntax

oShape = FindShapeAt( x, y )

Parameters

Returns

oShape as Shape: A shape object.

handle_canvas_mousedown

Dispatches the mousedown event to any specified decorators. Sets the MouseTrackLeft, MouseTrackTop, MouseTrackChoose, MouseTrackDown, and CurrentShape properties.

Syntax

void handle_canvas_mousedown( e )

Parameters

handle_canvas_mousemove

Dispatches the mousemove event to any specified decorators. Sets the MouseTrackLeft, MouseTrackTop, and MouseDropShape property.

Syntax

void handle_canvas_mousemove( e )

Parameters

handle_canvas_mouseup

Dispatches the mouseup event to any specified decorators. Clears MouseTrack* properties.

Syntax

void handle_canvas_mouseup( e )

Parameters

Initialize

Initializes the Canvas Class.

Syntax

void Initialize( )

NewCircle

Creates a new Circle Shape.

Syntax

oShape = NewCircle( x, y, r, sFill, sStroke )

Parameters

Returns

oShape as Shape: A new shape object.

NewEllipse

Creates a new Ellipse Shape.

Syntax

oShape = NewEllipse( x, y, x2, y2, sFill, sStroke )

Parameters

Returns

oShape as Shape: A new shape object.

NewRect

Creates a new Rect Shape.

Syntax

oShape = NewRect( x, y, w, h, sFill, sStroke )

Parameters

Returns

oShape as Shape: A new shape object.

NewRoundedRect

Creates a new RoundedRect Shape.

Syntax

oShape = NewRoundedRect( x, y, w, h, sFill, sStroke )

Parameters

Returns

oShape as Shape: A new shape object.

NewShape

Creates a new Shape.

Syntax

oShape = NewShape( index, sType, sFill, sStroke )

Parameters

Returns

oShape as Shape: A new shape object.

NewText

Creates a new Text Shape.

Syntax

oShape = NewText( sText, x, y, sFill, sStroke )

Parameters

Returns

oShape as Shape: A new shape object.

Rasterize

Moves the shapes from the temporary canvas to the fixed canvas.

Syntax

void Rasterize( )

Resize

Resizes the canvas and temporary canvas elements.

Syntax

void Resize( width, height )

Parameters

ShapeAt

Returns the first shape at the specified coordinates, and caches the location until the canvas is cleared.

Syntax

oShape = ShapeAt( x, y )

Parameters

Returns

oShape as Shape: A shape object.