Guest User

Switch between visible layers in SVG

a guest
Aug 12th, 2011
548
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!-- Created with Inkscape (http://www.inkscape.org/) -->
  3.  
  4. <svg
  5.   xmlns:dc="http://purl.org/dc/elements/1.1/"
  6.   xmlns:cc="http://creativecommons.org/ns#"
  7.   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  8.   xmlns:svg="http://www.w3.org/2000/svg"
  9.   xmlns="http://www.w3.org/2000/svg"
  10.   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
  11.   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
  12.   width="200"
  13.   height="200"
  14.   id="svg2"
  15.   version="1.1"
  16.   inkscape:version="0.48.1 r9760"
  17.   sodipodi:docname="Nytt dokument 1">
  18.   <defs
  19.     id="defs4" />
  20.   <script type="application/ecmascript"> <![CDATA[
  21.    var visibleLayer = 'layer1';
  22.     function goToLayer(layer) {
  23.     document.getElementById(visibleLayer).setAttribute('style', 'display: none');
  24.     document.getElementById(layer).setAttribute('style', 'display: inline');
  25.     visibleLayer = layer;
  26.    }
  27.  ]]> </script>        
  28.   <sodipodi:namedview
  29.     id="base"
  30.     pagecolor="#ffffff"
  31.     bordercolor="#666666"
  32.     borderopacity="1.0"
  33.     inkscape:pageopacity="0.0"
  34.     inkscape:pageshadow="2"
  35.     inkscape:zoom="3.45"
  36.     inkscape:cx="63.913043"
  37.     inkscape:cy="100"
  38.     inkscape:document-units="px"
  39.     inkscape:current-layer="layer2"
  40.     showgrid="false"
  41.     inkscape:window-width="1440"
  42.     inkscape:window-height="876"
  43.     inkscape:window-x="0"
  44.     inkscape:window-y="24"
  45.     inkscape:window-maximized="1" />
  46.   <metadata
  47.     id="metadata7">
  48.     <rdf:RDF>
  49.       <cc:Work
  50.         rdf:about="">
  51.         <dc:format>image/svg+xml</dc:format>
  52.         <dc:type
  53.           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
  54.         <dc:title></dc:title>
  55.       </cc:Work>
  56.     </rdf:RDF>
  57.   </metadata>
  58.   <g
  59.     inkscape:label="layer1"
  60.     inkscape:groupmode="layer"
  61.     id="layer1"
  62.     transform="translate(0,-852.36218)"
  63.     style="display:inline">
  64.     <rect
  65.       style="fill:#000080;fill-opacity:1;stroke:none"
  66.       id="rect2986"
  67.       width="149.56522"
  68.       height="108.4058"
  69.       x="20"
  70.       y="21.73913"
  71.       transform="translate(0,852.36218)"
  72.       onclick="goToLayer('layer2');" />
  73.   </g>
  74.   <g
  75.     inkscape:groupmode="layer"
  76.     id="layer2"
  77.     inkscape:label="layer2"
  78.     style="display:none">
  79.     <path
  80.       sodipodi:type="arc"
  81.       style="fill:#000080;fill-opacity:1;stroke:none"
  82.       id="path2988"
  83.       sodipodi:cx="97.826088"
  84.       sodipodi:cy="89.130432"
  85.       sodipodi:rx="59.275364"
  86.       sodipodi:ry="42.753624"
  87.       d="m 157.10145,89.130432 a 59.275364,42.753624 0 1 1 -118.550726,0 59.275364,42.753624 0 1 1 118.550726,0 z"
  88.       onclick="goToLayer('layer1');" />
  89.   </g>
  90. </svg>
RAW Paste Data