<divid=Content><divclass="CFile"><divclass=CTopicid=MainTopic><h1class=CTitle><aname="svgcanvas.js"></a>svgcanvas.js</h1><divclass=CBody><!--START_ND_SUMMARY--><divclass=Summary><divclass=STitle>Summary</div><divclass=SBorder><tableborder=0cellspacing=0cellpadding=0class=STable><trclass="SMain"><tdclass=SEntry><ahref="#svgcanvas.js">svgcanvas.js</a></td><tdclass=SDescription></td></tr><trclass="SGroup"><tdclass=SEntry><ahref="#Functions">Functions</a></td><tdclass=SDescription></td></tr><trclass="SFunction SIndent1 SMarked"><tdclass=SEntry><ahref="#clearSelection"id=link1onMouseOver="ShowTip(event, 'tt1', 'link1')"onMouseOut="HideTip('tt1')">clearSelection</a></td><tdclass=SDescription>Clears the selection. </td></tr><trclass="SFunction SIndent1"><tdclass=SEntry><ahref="#addToSelection"id=link2onMouseOver="ShowTip(event, 'tt2', 'link2')"onMouseOut="HideTip('tt2')">addToSelection</a></td><tdclass=SDescription>Adds a list of elements to the selection. </td></tr><trclass="SFunction SIndent1 SMarked"><tdclass=SEntry><ahref="#removeFromSelection"id=link3onMouseOver="ShowTip(event, 'tt3', 'link3')"onMouseOut="HideTip('tt3')">removeFromSelection</a></td><tdclass=SDescription>Removes elements from the selection.</td></tr><trclass="SFunction SIndent1"><tdclass=SEntry><ahref="#save"id=link4onMouseOver="ShowTip(event, 'tt4', 'link4')"onMouseOut="HideTip('tt4')">save</a></td><tdclass=SDescription>Serializes the current drawing into SVG XML text and returns it to the ‘saved’ handler. </td></tr><trclass="SFunction SIndent1 SMarked"><tdclass=SEntry><ahref="#getSvgString"id=link5onMouseOver="ShowTip(event, 'tt5', 'link5')"onMouseOut="HideTip('tt5')">getSvgString</a></td><tdclass=SDescription>Returns the current drawing as raw SVG XML text.</td></tr><trclass="SFunction SIndent1"><tdclass=SEntry><ahref="#setSvgString"id=link6onMouseOver="ShowTip(event, 'tt6', 'link6')"onMouseOut="HideTip('tt6')">setSvgString</a></td><tdclass=SDescription>This function sets the current drawing as the input SVG XML.</td></tr><trclass="SFunction SIndent1 SMarked"><tdclass=SEntry><ahref="#createLayer"id=link7onMouseOver="ShowTip(event, 'tt7', 'link7')"onMouseOut="HideTip('tt7')">createLayer</a></td><tdclass=SDescription>Creates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler. </td></tr><trclass="SFunction SIndent1"><tdclass=SEntry><ahref="#deleteCurrentLayer"id=link8onMouseOver="ShowTip(event, 'tt8', 'link8')"onMouseOut="HideTip('tt8')">deleteCurrentLayer</a></td><tdclass=SDescription>Deletes the current layer from the drawing and then clears the selection. </td></tr><trclass="SFunction SIndent1 SMarked"><tdclass=SEntry><ahref="#getNumLayers"id=link9onMouseOver="ShowTip(event, 'tt9', 'link9')"onMouseOut="HideTip('tt9')">getNumLayers</a></td><tdclass=SDescription>Returns the number of layers in the current drawing.</td></tr><trclass="SFunction SIndent1"><tdclass=SEntry><ahref="#getLayer"id=link10onMouseOver="ShowTip(event, 'tt10', 'link10')"onMouseOut="HideTip('tt10')">getLayer</a></td><tdclass=SDescription>Returns the name of the ith layer. </td></tr><trclass="SFunction SIndent1 SMarked"><tdclass=SEntry><ahref="#getCurrentLayer"id=link11onMouseOver="ShowTip(event, 'tt11', 'link11')"onMouseOut="HideTip('tt11')">getCurrentLayer</a></td><tdclass=SDescription>Returns the name of the currently selected layer. </td></tr><trclass="SFunction SIndent1"><tdclass=SEntry><ahref="#setCurrentLayer"id=link12onMouseOver="ShowTip(event, 'tt12', 'link12')"onMouseOut="HideTip('tt12')">setCurrentLayer</a></td><tdclass=SDescription>Sets the current layer. </td></tr><trclass="SFunction SIndent1 SMarked"><tdclass=SEntry><ahref="#renameCurrentLayer"id=link13onMouseOver="ShowTip(event, 'tt13', 'link13')"onMouseOut="HideTip('tt13')">renameCurrentLayer</a></td><tdclass=SDescription>Renames the current layer. </td></tr><trclass="SFu
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="clearSelection"></a>clearSelection</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.clearSelection = function()</td></tr></table></blockquote><p>Clears the selection. The ‘selected’ handler is then called.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="addToSelection"></a>addToSelection</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.addToSelection = function(</td><tdclass=PParameternowrap>elemsToAdd,</td></tr><tr><td></td><tdclass=PParameternowrap>showGrips</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Adds a list of elements to the selection. The ‘selected’ handler is then called.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>elemsToAdd</td><tdclass=CDLDescription>an array of DOM elements to add to the selection</td></tr><tr><tdclass=CDLEntry>showGrips</td><tdclass=CDLDescription>a boolean flag indicating whether the resize grips should be shown</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="removeFromSelection"></a>removeFromSelection</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.removeFromSelection = function(</td><tdclass=PParameternowrap>elemsToRemove</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Removes elements from the selection.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>elemsToRemove</td><tdclass=CDLDescription>an array of elements to remove from selection</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="save"></a>save</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.save = function()</td></tr></table></blockquote><p>Serializes the current drawing into SVG XML text and returns it to the ‘saved’ handler. This function also includes the XML prolog.</p><h4class=CHeading>Returns</h4><p>Nothing</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="getSvgString"></a>getSvgString</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.getSvgString = function()</td></tr></table></blockquote><p>Returns the current drawing as raw SVG XML text.</p><h4class=CHeading>Returns</h4><p>The current drawing as raw SVG XML text.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="setSvgString"></a>setSvgString</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.setSvgString = function(</td><tdclass=PParameternowrap>xmlString</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>This function sets the current drawing as the input SVG XML.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>xmlString</td><tdclass=CDLDescription>The SVG as XML text.</td></tr></table><h4class=CHeading>Returns</h4><p>This function returns false if the set was unsuccessful, true otherwise.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="createLayer"></a>createLayer</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.createLayer = function(</td><tdclass=PParameternowrap>name</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Creates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler. This is an undoable action.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>name</td><tdclass=CDLDescription>The given name</td></tr></table></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="deleteCurrentLayer"></a>deleteCurrentLayer</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.deleteCurrentLayer = function()</td></tr></table></blockquote><p>Deletes the current layer from the drawing and then clears the selection. This function then calls the ‘changed’ handler. This is an undoable action.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="getNumLayers"></a>getNumLayers</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.getNumLayers = function()</td></tr></table></blockquote><p>Returns the number of layers in the current drawing.</p><h4class=CHeading>Returns</h4><p>The number of layers in the current drawing.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="getLayer"></a>getLayer</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.getLayer = function(</td><tdclass=PParameternowrap>i</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the name of the ith layer. If the index is out of range, an empty string is returned.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>i</td><tdclass=CDLDescription>the zero-based index of the layer you are querying.</td></tr></table><h4class=CHeading>Returns</h4><p>The name of the ith layer</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="getCurrentLayer"></a>getCurrentLayer</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.getCurrentLayer = function()</td></tr></table></blockquote><p>Returns the name of the currently selected layer. If an error occurs, an empty string is returned.</p><h4class=CHeading>Returns</h4><p>The name of the currently active layer.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="setCurrentLayer"></a>setCurrentLayer</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.setCurrentLayer = function(</td><tdclass=PParameternowrap>name</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Sets the current layer. If the name is not a valid layer name, then this function returns false. Otherwise it returns true. This is not an undo-able action.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>name</td><tdclass=CDLDescription>the name of the layer you want to switch to.</td></tr></table><h4class=CHeading>Returns</h4><p>true if the current layer was switched, otherwise false</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="renameCurrentLayer"></a>renameCurrentLayer</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.renameCurrentLayer = function(</td><tdclass=PParameternowrap>newname</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Renames the current layer. If the layer name is not valid (i.e. unique), then this function does nothing and returns false, otherwise it returns true. This is an undo-able action.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>newname</td><tdclass=CDLDescription>the new name you want to give the current layer. This name must be unique among all layer names.</td></tr></table><h4class=CHeading>Returns</h4><p>true if the rename succeeded, false otherwise.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="setCurrentLayerPosition"></a>setCurrentLayerPosition</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.setCurrentLayerPosition = function(</td><tdclass=PParameternowrap>newpos</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Changes the position of the current layer to the new value. If the new index is not valid, this function does nothing and returns false, otherwise it returns true. This is an undo-able action.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>newpos</td><tdclass=CDLDescription>The zero-based index of the new position of the layer. This should be between</td></tr><tr><tdclass=CDLEntry>0 and (number of layers</td><tdclass=CDLDescription>1)</td></tr></table><h4class=CHeading>Returns</h4><p>true if the current layer position was changed, false otherwise.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="getLayerVisibility"></a>getLayerVisibility</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.getLayerVisibility = function(</td><tdclass=PParameternowrap>layername</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns whether the layer is visible. If the layer name is not valid, then this function returns false.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>layername</td><tdclass=CDLDescription>the name of the layer which you want to query.</td></tr></table><h4class=CHeading>Returns</h4><p>The visibility state of the layer, or false if the layer name was invalid.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="setLayerVisibility"></a>setLayerVisibility</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.setLayerVisibility = function(</td><tdclass=PParameternowrap>layername,</td></tr><tr><td></td><tdclass=PParameternowrap>bVisible</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Sets the visibility of the layer. If the layer name is not valid, this function return false, otherwise it returns true. This is an undo-able action.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>layername</td><tdclass=CDLDescription>the name of the layer to change the visibility</td></tr><tr><tdclass=CDLEntry>bVisible</td><tdclass=CDLDescription>true/false, whether the layer should be visible</td></tr></table><h4class=CHeading>Returns</h4><p>true if the layer’s visibility was set, false otherwise</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="moveSelectedToLayer"></a>moveSelectedToLayer</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.moveSelectedToLayer = function(</td><tdclass=PParameternowrap>layername</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote><p>Moves the selected elements to layername. If the name is not a valid layer name, then false is returned. Otherwise it returns true. This is an undo-able action.</p><h4class=CHeading>Parameters</h4><tableborder=0cellspacing=0cellpadding=0class=CDescriptionList><tr><tdclass=CDLEntry>layername</td><tdclass=CDLDescription>the name of the layer you want to which you want to move the selected elements</td></tr></table><h4class=CHeading>Returns</h4><p>true if the selected elements were moved to the layer, false otherwise.</p></div></div></div>
<divclass="CFunction"><divclass=CTopic><h3class=CTitle><aname="clear"></a>clear</h3><divclass=CBody><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.clear = function()</td></tr></table></blockquote><p>Clears the current document. This is not an undoable action.</p></div></div></div>
<divclass=CToolTipid="tt1"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.clearSelection = function()</td></tr></table></blockquote>Clears the selection. </div></div><divclass=CToolTipid="tt2"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.addToSelection = function(</td><tdclass=PParameternowrap>elemsToAdd,</td></tr><tr><td></td><tdclass=PParameternowrap>showGrips</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Adds a list of elements to the selection. </div></div><divclass=CToolTipid="tt3"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.removeFromSelection = function(</td><tdclass=PParameternowrap>elemsToRemove</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Removes elements from the selection.</div></div><divclass=CToolTipid="tt4"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.save = function()</td></tr></table></blockquote>Serializes the current drawing into SVG XML text and returns it to the ‘saved’ handler. </div></div><divclass=CToolTipid="tt5"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.getSvgString = function()</td></tr></table></blockquote>Returns the current drawing as raw SVG XML text.</div></div><divclass=CToolTipid="tt6"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.setSvgString = function(</td><tdclass=PParameternowrap>xmlString</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>This function sets the current drawing as the input SVG XML.</div></div><divclass=CToolTipid="tt7"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.createLayer = function(</td><tdclass=PParameternowrap>name</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Creates a new top-level layer in the drawing with the given name, sets the current layer to it, and then clears the selection This function then calls the ‘changed’ handler. </div></div><divclass=CToolTipid="tt8"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.deleteCurrentLayer = function()</td></tr></table></blockquote>Deletes the current layer from the drawing and then clears the selection. </div></div><divclass=CToolTipid="tt9"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.getNumLayers = function()</td></tr></table></blockquote>Returns the number of layers in the current drawing.</div></div><divclass=CToolTipid="tt10"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdclass=PBeforeParametersnowrap>this.getLayer = function(</td><tdclass=PParameternowrap>i</td><tdclass=PAfterParametersnowrap>)</td></tr></table></td></tr></table></blockquote>Returns the name of the ith layer. </div></div><divclass=CToolTipid="tt11"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td>this.getCurrentLayer = function()</td></tr></table></blockquote>Returns the name of the currently selected layer. </div></div><divclass=CToolTipid="tt12"><divclass=CFunction><blockquote><tableborder=0cellspacing=0cellpadding=0class=Prototype><tr><td><tableborder=0cellspacing=0cellpadding=0><tr><tdc