instiki/public/svg-edit/docs/files/svgcanvas-js.html
Jacques Distler c3ed5b461b Preliminary SVG-edit Support
WYSIWYG SVG editing.

Still no support for mixed
SVG/MathML content, yet.
2010-02-05 21:36:35 -06:00

88 lines
33 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><title>/Users/jschill1/Documents/svg-edit/editor/svgcanvas.js</title><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script><script language=JavaScript src="../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad()"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>
<!-- Generated by Natural Docs, version 1.4 -->
<!-- http://www.naturaldocs.org -->
<!-- saved from url=(0026)http://www.naturaldocs.org -->
<div id=Content><div class="CFile"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="svgcanvas.js"></a>svgcanvas.js</h1><div class=CBody><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#svgcanvas.js" >svgcanvas.js</a></td><td class=SDescription></td></tr><tr class="SGroup"><td class=SEntry><a href="#Selection" >Selection</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#clearSelection" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">clearSelection</a></td><td class=SDescription>Clears the selection. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#addToSelection" id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">addToSelection</a></td><td class=SDescription>Adds a list of elements to the selection. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#removeFromSelection" id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">removeFromSelection</a></td><td class=SDescription>Removes elements from the selection.</td></tr><tr class="SGroup"><td class=SEntry><a href="#Serialization" >Serialization</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#open" id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">open</a></td><td class=SDescription>Calls the &lsquo;opened&rsquo; handler and sends the SVG XML text. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#save" id=link5 onMouseOver="ShowTip(event, 'tt5', 'link5')" onMouseOut="HideTip('tt5')">save</a></td><td class=SDescription>Serializes the current drawing into SVG XML text and returns it to the &lsquo;saved&rsquo; handler. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#getSvgString" id=link6 onMouseOver="ShowTip(event, 'tt6', 'link6')" onMouseOut="HideTip('tt6')">getSvgString</a></td><td class=SDescription>Returns the current drawing as raw SVG XML text.</td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#setSvgString" id=link7 onMouseOver="ShowTip(event, 'tt7', 'link7')" onMouseOut="HideTip('tt7')">setSvgString</a></td><td class=SDescription>This function sets the current drawing as the input SVG XML.</td></tr><tr class="SGroup"><td class=SEntry><a href="#Layers" >Layers</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#createLayer" id=link8 onMouseOver="ShowTip(event, 'tt8', 'link8')" onMouseOut="HideTip('tt8')">createLayer</a></td><td class=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 &lsquo;changed&rsquo; handler. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#deleteCurrentLayer" id=link9 onMouseOver="ShowTip(event, 'tt9', 'link9')" onMouseOut="HideTip('tt9')">deleteCurrentLayer</a></td><td class=SDescription>Deletes the current layer from the drawing and then clears the selection. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#getNumLayers" id=link10 onMouseOver="ShowTip(event, 'tt10', 'link10')" onMouseOut="HideTip('tt10')">getNumLayers</a></td><td class=SDescription>Returns the number of layers in the current drawing.</td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#getLayer" id=link11 onMouseOver="ShowTip(event, 'tt11', 'link11')" onMouseOut="HideTip('tt11')">getLayer</a></td><td class=SDescription>Returns the name of the ith layer. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#getCurrentLayer" id=link12 onMouseOver="ShowTip(event, 'tt12', 'link12')" onMouseOut="HideTip('tt12')">getCurrentLayer</a></td><td class=SDescription>Returns the name of the currently selected layer. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#setCurrentLayer" id=link13 onMouseOver="ShowTip(event, 'tt13', 'link13')" onMouseOut="HideTip('tt13')">setCurrentLayer</a></td><td class=SDescription>Sets the current layer. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#renameCurrentLayer" id=link14 onMouseOver="ShowTip(event, 'tt14', 'link14')" onMouseOut="HideTip('tt14')">renameCurrentLayer</a></td><td class=SDescription>Renames the current layer. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#setCurrentLayerPosition" id=link15 onMouseOver="ShowTip(event, 'tt15', 'link15')" onMouseOut="HideTip('tt15')">setCurrentLayerPosition</a></td><td class=SDescription>Changes the position of the current layer to the new value. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#getLayerVisibility" id=link16 onMouseOver="ShowTip(event, 'tt16', 'link16')" onMouseOut="HideTip('tt16')">getLayerVisibility</a></td><td class=SDescription>Returns whether the layer is visible. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#setLayerVisibility" id=link17 onMouseOver="ShowTip(event, 'tt17', 'link17')" onMouseOut="HideTip('tt17')">setLayerVisibility</a></td><td class=SDescription>Sets the visibility of the layer. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#moveSelectedToLayer" id=link18 onMouseOver="ShowTip(event, 'tt18', 'link18')" onMouseOut="HideTip('tt18')">moveSelectedToLayer</a></td><td class=SDescription>Moves the selected elements to layername. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#getLayerOpacity" id=link19 onMouseOver="ShowTip(event, 'tt19', 'link19')" onMouseOut="HideTip('tt19')">getLayerOpacity</a></td><td class=SDescription>Returns the opacity of the given layer. </td></tr><tr class="SFunction SIndent1 SMarked"><td class=SEntry><a href="#setLayerOpacity" id=link20 onMouseOver="ShowTip(event, 'tt20', 'link20')" onMouseOut="HideTip('tt20')">setLayerOpacity</a></td><td class=SDescription>Sets the opacity of the given layer. </td></tr><tr class="SFunction SIndent1"><td class=SEntry><a href="#clear" id=link21 onMouseOver="ShowTip(event, 'tt21', 'link21')" onMouseOut="HideTip('tt21')">clear</a></td><td class=SDescription>Clears the current document. </td></tr><tr class="SGroup"><td class=SEntry><a href="#Fill_and_Stroke" >Fill and Stroke</a></td><td class=SDescription></td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Selection"></a>Selection</h3></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="clearSelection"></a>clearSelection</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.clearSelection = function()</td></tr></table></blockquote><p>Clears the selection.&nbsp; The &lsquo;selected&rsquo; handler is then called.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="addToSelection"></a>addToSelection</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.addToSelection = function(</td><td class=PParameter nowrap>elemsToAdd,</td></tr><tr><td></td><td class=PParameter nowrap>showGrips</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Adds a list of elements to the selection.&nbsp; The &lsquo;selected&rsquo; handler is then called.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>elemsToAdd</td><td class=CDLDescription>an array of DOM elements to add to the selection</td></tr><tr><td class=CDLEntry>showGrips</td><td class=CDLDescription>a boolean flag indicating whether the resize grips should be shown</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="removeFromSelection"></a>removeFromSelection</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.removeFromSelection = function(</td><td class=PParameter nowrap>elemsToRemove</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Removes elements from the selection.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>elemsToRemove</td><td class=CDLDescription>an array of elements to remove from selection</td></tr></table></div></div></div>
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Serialization"></a>Serialization</h3></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="open"></a>open</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.open = function(</td><td class=PParameter nowrap>str</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Calls the &lsquo;opened&rsquo; handler and sends the SVG XML text.&nbsp; Clients of the SvgCanvas bind their load function (typically calls to setSvgString() to the &lsquo;opened&rsquo; event.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="save"></a>save</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.save = function()</td></tr></table></blockquote><p>Serializes the current drawing into SVG XML text and returns it to the &lsquo;saved&rsquo; handler.&nbsp; This function also includes the XML prolog.&nbsp; Clients of the SvgCanvas bind their save function to the &lsquo;saved&rsquo; event.</p><h4 class=CHeading>Returns</h4><p>Nothing</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="getSvgString"></a>getSvgString</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.getSvgString = function()</td></tr></table></blockquote><p>Returns the current drawing as raw SVG XML text.</p><h4 class=CHeading>Returns</h4><p>The current drawing as raw SVG XML text.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="setSvgString"></a>setSvgString</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.setSvgString = function(</td><td class=PParameter nowrap>xmlString</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>This function sets the current drawing as the input SVG XML.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>xmlString</td><td class=CDLDescription>The SVG as XML text.</td></tr></table><h4 class=CHeading>Returns</h4><p>This function returns false if the set was unsuccessful, true otherwise.</p></div></div></div>
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Layers"></a>Layers</h3></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="createLayer"></a>createLayer</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.createLayer = function(</td><td class=PParameter nowrap>name</td><td class=PAfterParameters nowrap>)</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 &lsquo;changed&rsquo; handler.&nbsp; This is an undoable action.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>name</td><td class=CDLDescription>The given name</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="deleteCurrentLayer"></a>deleteCurrentLayer</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.deleteCurrentLayer = function()</td></tr></table></blockquote><p>Deletes the current layer from the drawing and then clears the selection.&nbsp; This function then calls the &lsquo;changed&rsquo; handler.&nbsp; This is an undoable action.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="getNumLayers"></a>getNumLayers</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.getNumLayers = function()</td></tr></table></blockquote><p>Returns the number of layers in the current drawing.</p><h4 class=CHeading>Returns</h4><p>The number of layers in the current drawing.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="getLayer"></a>getLayer</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.getLayer = function(</td><td class=PParameter nowrap>i</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the name of the ith layer.&nbsp; If the index is out of range, an empty string is returned.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>i</td><td class=CDLDescription>the zero-based index of the layer you are querying.</td></tr></table><h4 class=CHeading>Returns</h4><p>The name of the ith layer</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="getCurrentLayer"></a>getCurrentLayer</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.getCurrentLayer = function()</td></tr></table></blockquote><p>Returns the name of the currently selected layer.&nbsp; If an error occurs, an empty string is returned.</p><h4 class=CHeading>Returns</h4><p>The name of the currently active layer.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="setCurrentLayer"></a>setCurrentLayer</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.setCurrentLayer = function(</td><td class=PParameter nowrap>name</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Sets the current layer.&nbsp; If the name is not a valid layer name, then this function returns false.&nbsp; Otherwise it returns true.&nbsp; This is not an undo-able action.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>name</td><td class=CDLDescription>the name of the layer you want to switch to.</td></tr></table><h4 class=CHeading>Returns</h4><p>true if the current layer was switched, otherwise false</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="renameCurrentLayer"></a>renameCurrentLayer</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.renameCurrentLayer = function(</td><td class=PParameter nowrap>newname</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Renames the current layer.&nbsp; If the layer name is not valid (i.e. unique), then this function does nothing and returns false, otherwise it returns true.&nbsp; This is an undo-able action.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>newname</td><td class=CDLDescription>the new name you want to give the current layer.&nbsp; This name must be unique among all layer names.</td></tr></table><h4 class=CHeading>Returns</h4><p>true if the rename succeeded, false otherwise.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="setCurrentLayerPosition"></a>setCurrentLayerPosition</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.setCurrentLayerPosition = function(</td><td class=PParameter nowrap>newpos</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Changes the position of the current layer to the new value.&nbsp; If the new index is not valid, this function does nothing and returns false, otherwise it returns true.&nbsp; This is an undo-able action.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>newpos</td><td class=CDLDescription>The zero-based index of the new position of the layer.&nbsp; This should be between</td></tr><tr><td class=CDLEntry>0 and (number of layers</td><td class=CDLDescription>1)</td></tr></table><h4 class=CHeading>Returns</h4><p>true if the current layer position was changed, false otherwise.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="getLayerVisibility"></a>getLayerVisibility</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.getLayerVisibility = function(</td><td class=PParameter nowrap>layername</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns whether the layer is visible.&nbsp; If the layer name is not valid, then this function returns false.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>layername</td><td class=CDLDescription>the name of the layer which you want to query.</td></tr></table><h4 class=CHeading>Returns</h4><p>The visibility state of the layer, or false if the layer name was invalid.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="setLayerVisibility"></a>setLayerVisibility</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.setLayerVisibility = function(</td><td class=PParameter nowrap>layername,</td></tr><tr><td></td><td class=PParameter nowrap>bVisible</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Sets the visibility of the layer.&nbsp; If the layer name is not valid, this function return false, otherwise it returns true.&nbsp; This is an undo-able action.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>layername</td><td class=CDLDescription>the name of the layer to change the visibility</td></tr><tr><td class=CDLEntry>bVisible</td><td class=CDLDescription>true/false, whether the layer should be visible</td></tr></table><h4 class=CHeading>Returns</h4><p>true if the layer&rsquo;s visibility was set, false otherwise</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="moveSelectedToLayer"></a>moveSelectedToLayer</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.moveSelectedToLayer = function(</td><td class=PParameter nowrap>layername</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Moves the selected elements to layername.&nbsp; If the name is not a valid layer name, then false is returned.&nbsp; Otherwise it returns true.&nbsp; This is an undo-able action.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>layername</td><td class=CDLDescription>the name of the layer you want to which you want to move the selected elements</td></tr></table><h4 class=CHeading>Returns</h4><p>true if the selected elements were moved to the layer, false otherwise.</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="getLayerOpacity"></a>getLayerOpacity</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.getLayerOpacity = function(</td><td class=PParameter nowrap>layername</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Returns the opacity of the given layer.&nbsp; If the input name is not a layer, null is returned.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>layername</td><td class=CDLDescription>name of the layer on which to get the opacity</td></tr></table><h4 class=CHeading>Returns</h4><p>The opacity value of the given layer.&nbsp; This will be a value between 0.0 and 1.0, or null if layername is not a valid layer</p></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="setLayerOpacity"></a>setLayerOpacity</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.setLayerOpacity = function(</td><td class=PParameter nowrap>layername,</td></tr><tr><td></td><td class=PParameter nowrap>opacity</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote><p>Sets the opacity of the given layer.&nbsp; If the input name is not a layer, nothing happens.&nbsp; This is not an undo-able action.&nbsp; NOTE: this function exists solely to apply a highlighting/de-emphasis effect to a layer, when it is possible for a user to affect the opacity of a layer, we will need to allow this function to produce an undo-able action.&nbsp; If opacity is not a value between 0.0 and 1.0, then nothing happens.</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>layername</td><td class=CDLDescription>name of the layer on which to set the opacity</td></tr><tr><td class=CDLEntry>opacity</td><td class=CDLDescription>a float value in the range 0.0-1.0</td></tr></table></div></div></div>
<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="clear"></a>clear</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.clear = function()</td></tr></table></blockquote><p>Clears the current document.&nbsp; This is not an undoable action.</p></div></div></div>
<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="Fill_and_Stroke"></a>Fill and Stroke</h3></div></div>
</div><!--Content-->
<div id=Footer><a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->
<div id=Menu><div class=MEntry><div class=MFile id=MSelected>svgcanvas.js</div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Index</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MIndex><a href="../index/General.html">Everything</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Files.html">Files</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Functions.html">Functions</a></div></div></div></div></div><script type="text/javascript"><!--
var searchPanel = new SearchPanel("searchPanel", "HTML", "../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option id=MSearchEverything selected value="General">Everything</option><option value="Files">Files</option><option value="Functions">Functions</option></select></div></div><!--Menu-->
<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.clearSelection = function()</td></tr></table></blockquote>Clears the selection. </div></div><div class=CToolTip id="tt2"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.addToSelection = function(</td><td class=PParameter nowrap>elemsToAdd,</td></tr><tr><td></td><td class=PParameter nowrap>showGrips</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Adds a list of elements to the selection. </div></div><div class=CToolTip id="tt3"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.removeFromSelection = function(</td><td class=PParameter nowrap>elemsToRemove</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Removes elements from the selection.</div></div><div class=CToolTip id="tt4"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.open = function(</td><td class=PParameter nowrap>str</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Calls the &lsquo;opened&rsquo; handler and sends the SVG XML text. </div></div><div class=CToolTip id="tt5"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.save = function()</td></tr></table></blockquote>Serializes the current drawing into SVG XML text and returns it to the &lsquo;saved&rsquo; handler. </div></div><div class=CToolTip id="tt6"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.getSvgString = function()</td></tr></table></blockquote>Returns the current drawing as raw SVG XML text.</div></div><div class=CToolTip id="tt7"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.setSvgString = function(</td><td class=PParameter nowrap>xmlString</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>This function sets the current drawing as the input SVG XML.</div></div><div class=CToolTip id="tt8"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.createLayer = function(</td><td class=PParameter nowrap>name</td><td class=PAfterParameters nowrap>)</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 &lsquo;changed&rsquo; handler. </div></div><div class=CToolTip id="tt9"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.deleteCurrentLayer = function()</td></tr></table></blockquote>Deletes the current layer from the drawing and then clears the selection. </div></div><div class=CToolTip id="tt10"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.getNumLayers = function()</td></tr></table></blockquote>Returns the number of layers in the current drawing.</div></div><div class=CToolTip id="tt11"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.getLayer = function(</td><td class=PParameter nowrap>i</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Returns the name of the ith layer. </div></div><div class=CToolTip id="tt12"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.getCurrentLayer = function()</td></tr></table></blockquote>Returns the name of the currently selected layer. </div></div><div class=CToolTip id="tt13"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.setCurrentLayer = function(</td><td class=PParameter nowrap>name</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Sets the current layer. </div></div><div class=CToolTip id="tt14"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.renameCurrentLayer = function(</td><td class=PParameter nowrap>newname</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Renames the current layer. </div></div><div class=CToolTip id="tt15"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.setCurrentLayerPosition = function(</td><td class=PParameter nowrap>newpos</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Changes the position of the current layer to the new value. </div></div><div class=CToolTip id="tt16"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.getLayerVisibility = function(</td><td class=PParameter nowrap>layername</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Returns whether the layer is visible. </div></div><div class=CToolTip id="tt17"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.setLayerVisibility = function(</td><td class=PParameter nowrap>layername,</td></tr><tr><td></td><td class=PParameter nowrap>bVisible</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Sets the visibility of the layer. </div></div><div class=CToolTip id="tt18"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.moveSelectedToLayer = function(</td><td class=PParameter nowrap>layername</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Moves the selected elements to layername. </div></div><div class=CToolTip id="tt19"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.getLayerOpacity = function(</td><td class=PParameter nowrap>layername</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Returns the opacity of the given layer. </div></div><div class=CToolTip id="tt20"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class=PBeforeParameters nowrap>this.setLayerOpacity = function(</td><td class=PParameter nowrap>layername,</td></tr><tr><td></td><td class=PParameter nowrap>opacity</td><td class=PAfterParameters nowrap>)</td></tr></table></td></tr></table></blockquote>Sets the opacity of the given layer. </div></div><div class=CToolTip id="tt21"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class=Prototype><tr><td>this.clear = function()</td></tr></table></blockquote>Clears the current document. </div></div><!--END_ND_TOOLTIPS-->
<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>
<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>