<source><name>Hemi.graphics.canvas</name><project><name>Hemi JavaScript Framework</name><url-title>Hemi JavaScript Framework Project</url-title><url>/Hemi/</url></project><package><path>Hemi.graphics.canvas</path><library>Hemi</library><description>The Canvas class provides a shape management layer for browsers that support Canvas, including a temporary drawing layer and event to shape coordination.</description><static-class><name>Canvas</name><version>3.1.9</version><description>Static initializer for CanvasInstance objects.</description><method><name>newInstance</name><param name="o" type="Node" optional="1">XHTML Node reference, either a canvas element, or an element into which a canvas should be created.</param><return-value type="CanvasInstance" name="oCanvas">A new instance of the Canvas class.</return-value><description>Creates a new instance of the Hemi Graphics Canvas class.</description></method></static-class><object><name>ShapeDecorator</name><version>3.1.9</version><description>A shape decorator receives event dispatches from the CanvasInstance allowing managed shapes to be manipulated in response to those events.  Event properties and positions are captured prior to the event being dispatched to the decorator, and are available on the CanvasInstance.properties member.</description><method virtual="1"><name>handle_canvas_mousedown</name><param name="oCanvas" type="CanvasInstance">A reference to the CanvasInstance.</param><param name="vEvent" type="event">The event captured for the Canvas.</param><description>Dispatched by the CanvasIntance for a mousedown event.</description></method><method virtual="1"><name>handle_canvas_mousemove</name><param name="oCanvas" type="CanvasInstance">A reference to the CanvasInstance.</param><param name="vEvent" type="event">The event captured for the Canvas.</param><description>Dispatched by the CanvasIntance for a mousemove event.</description></method><method virtual="1"><name>handle_canvas_mouseup</name><param name="oCanvas" type="CanvasInstance">A reference to the CanvasInstance.</param><param name="vEvent" type="event">The event captured for the Canvas.</param><description>Dispatched by the CanvasIntance for a mouseup event.</description></method></object><class><name>CanvasInstance</name><version>3.1.9</version><description>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.</description>
shapes contains object representations of vectors applied to the canvas

temp_shapes contains shapes currently applied to the temporary canvas

shape_track_map is a jagged array of x-axis[int],y-axis[int],node_indices[]

<method internal="1"><name>Initialize</name><description>Initializes the Canvas Class.</description></method>
If context is still undefined, leave

<object><name>ContextConfig</name><description>Applies configuration to the context.</description><property get="1" name="stroke" type="variant">Stroke style</property><property get="1" name="fill" type="variant">Fill style</property><property get="1" name="alpha" type="variant">Global alpha</property><property get="1" name="lineWidth" type="variant">Line width</property><property get="1" name="lineCap" type="variant">Line cap</property><property get="1" name="lineJoin" type="variant">Line join</property><property get="1" name="miterLimit" type="variant">Miter limit</property><property get="1" name="shadowOffsetX" type="variant">Shadow offset X</property><property get="1" name="shadowOffsetY" type="variant">Shadow offset Y</property><property get="1" name="shadowColor" type="variant">Shadow color</property><property get="1" name="globalComposite" type="variant">Global composite operation</property><property get="1" name="font" type="variant">Font</property><property get="1" name="textAlign" type="variant">Text align</property><property get="1" name="textBaseline" type="variant">Text baseline</property></object><method><name>getContextConfigByName</name><param name="name" type="String">The name of the configuration</param><return-value name="cfg" type="ContextConfig">The context configuration.</return-value></method><method><name>newContextConfig</name><description>Applies configuration to the context.</description><param name="name" type="String">The name of the configuration.</param><param optional="1" name="stroke" type="variant">Stroke style</param><param optional="1" name="fill" type="variant">Fill style</param><param optional="1" name="alpha" type="variant">Global alpha</param><param optional="1" name="lWidth" type="variant">Line width</param><param optional="1" name="lCap" type="variant">Line cap</param><param optional="1" name="lJoin" type="variant">Line join</param><param optional="1" name="miter" type="variant">Miter limit</param><param optional="1" name="shadowX" type="variant">Shadow offset X</param><param optional="1" name="shadowY" type="variant">Shadow offset Y</param><param optional="1" name="shadowColor" type="variant">Shadow color</param><param optional="1" name="composite" type="variant">Global composite operation</param><param optional="1" name="font" type="variant">Font</param><param optional="1" name="textAlign" type="variant">Text align</param><param optional="1" name="textBaseline" type="variant">Text baseline</param></method><method><name>setTemporaryContextConfig</name><param name="cfg" type="ContextConfig">The context configuration</param><description>Applies the specified context configuration to the context.</description></method><method><name>getContextConfig</name><param name="ctx" type="Context" optional="1">Context from which the configuration is queried.</param><return-value name="cfg" type="ContextConfig">The context configuration.</return-value><description>Returns the current context configuration as applied to the context.</description></method><method><name>getContext</name><description>Returns the Canvas 2D Context.</description><return-value name="ctx" type="Context">The Canvas 2D Context</return-value></method><method><name>getTemporaryContext</name><description>Returns the Temporary Canvas 2D Context.</description><return-value name="ctx" type="Context">The Canvas 2D Context</return-value></method><method><name>AddShapeDecorator</name><description>Adds a ShapeDecorator to the canvas.</description></method><method><name>Clear</name><description>Clears the Canvas and Temporary Canvas shapes and drawings.</description></method><method><name>ClearTempCanvas</name><description>Clears the Temporary Canvas shapes and drawings.</description></method><method><name>ClearCanvas</name><description>Clears the Canvas shapes and drawings.</description></method>
TODO: Delete non-vectors based on shape property, not blind delete all spans

<method><name>Draw</name><param name="oShape" type="Shape">The shape to be drawn.</param><param name="bStroke" type="boolean">Bit indicating whether the shape should be stroked.</param><param name="bFix" type="boolean" optional="1">Dev value.</param><description>Draws the specified shape onto the temporary canvas.</description></method>
this.DrawArc(o.x, o.y, o.radius, o.startAngle, o.endAngle, b, o.fillStyle, o.strokeStyle);
<method internal="1"><name>DrawPolygon</name><param name="oShape" type="Shape">The shape to be drawn.</param><description>Draws a polygon.</description></method>
Hemi.log("Fill = " + o.fillStyle);
Hemi.log("Line " + p + ": " + oLP.x + "," + oLP.y);
Hemi.log("Line: " + oLP.x + "," + oLP.y);
<method internal="1"><name>DrawRoundedRect</name><param name="oShape" type="Shape">The shape to be drawn.</param><description>Draws a rounded rectangular shape.  This function is based on the <a href="http://canvaspaint.org">CanvasPaint</a> paint.js implementation.</description></method>
RoundedRect  based on CanvasPaint's paint.js - http://canvaspaint.org

<method internal="1"><name>DrawEllipse</name><param name="oShape" type="Shape">The shape to be drawn.</param><description>Draws an ellipse shape.  This function is based on the <a href="http://canvaspaint.org">CanvasPaint</a> paint.js implementation.</description></method>
Elipse  based on CanvasPaint blog - http://canvaspaint.org/blog/2006/12/ellipse/

<method internal="1"><name>DrawArc</name><param name="oShape" type="Shape">The shape to be drawn.</param><description>Draws an arc shape.</description></method>
n.DrawArc = function (x, y, r, s, e, b, f, c) {
o.x, o.y, o.radius, o.startAngle, o.endAngle, b, o.fillStyle, o.strokeStyle
if (!f) f = tc2.fillStyle;
if (!c) c = f;
<method internal="1"><name>DrawRect</name><param name="oShape" type="Shape">The shape to be drawn.</param><description>Draws a rectangular shape.</description></method>
tc2 = _p[(o.rendered ? "canvas_2d" : "temp_canvas_2d")];
alert(x + "," + y + "\n" + w + "," + h);
tc2[(b ? "strokeRect" : "fillRect")](x, y, w, h);
alert(b + "?" + f + "\n" + c);
<method internal="1"><name>DrawText</name><param name="oShape" type="Shape">The shape to be drawn.</param><description>Draws a text shape.  If the measureText method is not implemented, a positioned HTML element is used to supply the text.</description></method>
this.log("Draw Text at " + vX + ", " + vY);
this.log("Draw Text at " + vX + ", " + vY);
<method><name>ConnectShapes</name><param name="oShape" type="Shape">The source shape to be connected.</param><param name="oShape" type="Shape">The target shape to be connected.</param><param name="sType" type="String" optional="1">Type of connection to draw. Currently supports "line" and "elbow" (default).</param><description>Draws a connection between the two shapes.</description></method>
positive o2 horz position
if (x2 &gt;= x1) {
top center 1
&gt;=
x2 is over or off-center-right of x1
top center
y2 is at least half-way above y1
bottom center
right center
left center 1
left center 1
bottom center 2
negative vert position
left center 2
}
Negative 2o horz position
top center 1
left center1
bottom center 2
Straight Line

Elbow Connector

<method><name>Rasterize</name><description>Moves the shapes from the temporary canvas to the fixed canvas.</description></method>
Repaint temp objects from the temp canvas to the final canvas

<method><name>NewEllipse</name><param name="x" type="int">First x axis.</param><param name="y" type="int">First y axis.</param><param name="x2" type="int">Second x axis.</param><param name="y2" type="int">Second y axis.</param><param name="sFill" type="String">Fill color.</param><param name="sStroke" type="String">Stroke color.</param><return-value name="oShape" type="Shape">A new shape object.</return-value><description>Creates a new Ellipse Shape.</description></method><method><name>NewArc</name><param name="x" type="int">X axis.</param><param name="y" type="int">Y axis.</param><param name="r" type="float">Radius.</param><param name="s" type="float">Start angle (degrees).</param><param name="e" type="float">End angle (degrees).</param><param name="b" type="float">Stroke to slice.</param><param name="sFill" type="String">Fill color.</param><param name="sStroke" type="String">Stroke color.</param><return-value name="oShape" type="Shape">A new shape object.</return-value><description>Creates a new Circle Shape.</description></method><method><name>NewCircle</name><param name="x" type="int">X axis.</param><param name="y" type="int">Y axis.</param><param name="r" type="float">Radius.</param><param name="sFill" type="String">Fill color.</param><param name="sStroke" type="String">Stroke color.</param><return-value name="oShape" type="Shape">A new shape object.</return-value><description>Creates a new Circle Shape.</description></method><method><name>NewText</name><param name="sText" type="String">The text value.</param><param name="x" type="int">X axis.</param><param name="y" type="int">Y axis.</param><param name="sFill" type="String">Fill color.</param><param name="sFz" type="String">Font size</param><param name="sFf" type="String">Font family.</param><return-value name="oShape" type="Shape">A new shape object.</return-value><description>Creates a new Text Shape.</description></method><method><name>NewRoundedRect</name><param name="x" type="int">X axis.</param><param name="y" type="int">Y axis.</param><param name="w" type="int">Width.</param><param name="h" type="int">Height.</param><param name="sFill" type="String">Fill color.</param><param name="sStroke" type="String">Stroke color.</param><return-value name="oShape" type="Shape">A new shape object.</return-value><description>Creates a new RoundedRect Shape.</description></method><object><name>Point</name><description>Object that describes a point.</description><property name="x" type="int" get="1" private="1">X position of the point.</property><property name="y" type="int" get="1" private="1">Y position of the point.</property></object><method><name>NewPoint</name><param name="x" type="int">X axis.</param><param name="y" type="int">Y axis.</param><return-value name="oPoint" type="Point">A point object.</return-value><description>Creates a new Point.</description></method><method><name>NewTriangle</name><param name="x" type="int">X axis.</param><param name="y" type="int">Y axis.</param><param name="w" type="int">Width.</param><param name="h" type="int">Height.</param><param name="sFill" type="String">Fill color.</param><param name="sStroke" type="String">Stroke color.</param><return-value name="oShape" type="Shape">A new isoscelese triangle object.</return-value><description>Creates a new isoscelese Triangle Shape.</description></method>
Top
Left
Right
<method><name>NewPolygon</name><param name="aPoints" type="Array&lt;Point&gt;">Array of points.</param><param name="sFill" type="String">Fill color.</param><param name="sStroke" type="String">Stroke color.</param><return-value name="oShape" type="Shape">A new shape object.</return-value><description>Creates a new Polygon Shape.</description></method><method><name>NewRect</name><param name="x" type="int">X axis.</param><param name="y" type="int">Y axis.</param><param name="w" type="int">Width.</param><param name="h" type="int">Height.</param><param name="sFill" type="String">Fill color.</param><param name="sStroke" type="String">Stroke color.</param><return-value name="oShape" type="Shape">A new shape object.</return-value><description>Creates a new Rect Shape.</description></method><object><name>Shape</name><description>Object that describes a shape that can be rendered to the Canvas.</description><property name="index" type="int" get="1" private="1">Index of the shape in the shapes array.</property><property type="String" get="1" name="type">The type of the shape.</property><property type="int" get="1" private="1" name="layerIndex">Dev only.</property><property type="int" get="1" private="1" name="x">The shape x axis.  Applies to limited shapes.</property><property type="int" get="1" private="1" name="x2">The second shape x axis.  Applies to limited shapes.</property><property type="int" get="1" private="1" name="y">The shape y axis.  Applies to limited shapes.</property><property type="int" get="1" private="1" name="y2">The second shape y axis.  Applies to limited shapes.</property><property type="float" get="1" private="1" name="kappa">The shape kappa.  Applies to limited shapes.</property><property type="float" get="1" name="startAngle">The beginning arc position.  Applies to limited shapes.</property><property type="float" get="1" name="endAngle">The ending arc position.  Applies to limited shapes.</property><property type="float" get="1" name="radius">The arc radius.  Applies to limited shapes.</property><property type="int" get="1" private="1" name="width">The shape width.  Applies to limited shapes.</property><property type="int" get="1" private="1" name="height">The shape height.  Applies to limited shapes.</property><property type="String" get="1" private="1" name="text">The text value.  Applies to text shapes.</property><property type="array" get="1" private="1" name="children">Dev only.</property><property type="int" get="1" private="1" name="parent">Dev only.</property><property type="int" get="1" name="reference_id">Placeholder for coordinating shape objects with other objects.</property><property type="boolean" get="1" name="selectable">Bit indicating whether the shape should be captured as a source or target prior to dispatching events to any specified decorators.</property><property type="boolean" get="1" private="1" name="is_html">Bit indicating whether HTML was used to accommodate an incomplete Canvas implemenetation.</property><property type="String" get="1" name="fillStyle">The fill style for the shape.</property><property type="String" get="1" name="strokeStyle">The stroke style for the shape.</property><property type="String" get="1" name="id">The shape identifier.</property><property type="boolean" get="1" name="rendered">Bit indicating whether the shape has been rendered.</property></object><method internal="1"><name>NewShape</name><param name="index" type="int">The internal index of the shape in the shapes array.</param><param name="sType" type="String">The type of the shape.</param><param name="sFill" type="String">Fill color.</param><param name="sStroke" type="String">Stroke color.</param><return-value name="oShape" type="Shape">A new shape object.</return-value><description>Creates a new Shape.</description></method><method><name>ShapeAt</name><param name="x" type="int">The x axis.</param><param name="y" type="int">The y axis.</param><return-value name="oShape" type="Shape">A shape object.</return-value><description>Returns the first shape at the specified coordinates, and caches the location until the canvas is cleared.</description></method><method internal="1"><name>FindShapeAt</name><param name="x" type="int">The x axis.</param><param name="y" type="int">The y axis.</param><return-value name="oShape" type="Shape">A shape object.</return-value><description>Finds a shape at the specified coordinates.</description></method>
Not valid - replace with point - circle intersection

HemiEngine.message.service.sendMessage("Skip: " + oShape.type + " : " + oShape.x);
<method internal="1"><name>handle_canvas_mousemove</name><param name="e" type="event">Event.</param><description>Dispatches the mousemove event to any specified decorators.  Sets the MouseTrackLeft, MouseTrackTop, and MouseDropShape property.</description></method><method internal="1"><name>handle_canvas_mouseup</name><param name="e" type="event">Event.</param><description>Dispatches the mouseup event to any specified decorators. Clears MouseTrack* properties.</description></method><property type="Shape" get="1"><name>properties.MouseDropShape</name><description>The shape at the current MouseTrackLeft and MouseTrackTop location.</description></property><property type="Shape" get="1"><name>properties.CurrentShape</name><description>The shape at the MouseTrackLeft and MouseTrackTop location where the mousedown event fired.</description></property><property type="boolean" get="1"><name>properties.MouseTrackDown</name><description>Bit indicating whether the mousedown event is in effect.</description></property><property type="boolean" get="1"><name>properties.MouseTrackChoose</name><description>Bit indicating whether the mousedown event captured a shape.</description></property><property type="int" get="1"><name>properties.MouseTrackLeft</name><description>The left axis of the mouse in the canvas.</description></property><property type="int" get="1"><name>properties.MouseTrackTop</name><description>The top axis of the mouse in the canvas.</description></property><property type="int" get="1"><name>properties.MouseOffsetX</name><description>The left offset of the mouse position from the shape edge.</description></property><property type="int" get="1"><name>properties.MouseOffsetY</name><description>The top offset of the mouse position from the shape edge.</description></property><method internal="1"><name>dispatch_decorators</name><param name="e" type="event">Event.</param><description>Dispatches the specified event to specified decorators.</description></method>
this.log("Dispatch " + e.type + " to " + aD.length + " decorators");
<method internal="1"><name>handle_canvas_mousedown</name><param name="e" type="event">Event.</param><description>Dispatches the mousedown event to any specified decorators. Sets the MouseTrackLeft, MouseTrackTop, MouseTrackChoose, MouseTrackDown, and CurrentShape properties.</description></method><method internal="1"><name>_handle_canvas_mouse</name><param name="e" type="event">Event.</param><description>Routes mouse events.</description></method><method><name>Resize</name><param name="width" type="String">New width value.</param><param name="height" type="String">New height value.</param><description>Resizes the canvas and temporary canvas elements.</description></method></class></package><index><description>The Canvas class provides a shape management layer for browsers that support Canvas, including a temporary drawing layer and event to shape coordination.</description><url>Hemi_api.html</url><url-title>API Index</url-title></index></source>
