Gary Frederick wrote:

Someone on the svg-developers mailing list answered a related question from me with:

So these are more or less ASV specific. In particular Batik implements getCTM correctly so it returns the transform to the nearest viewport. The closest thing to what ASV does with getCTM is: e.getTransformToElement(e.getParent());

   Batik also implements the 'getTransform()' method which is
actually quite combersom to use:

        SVGTransform trans;
        trans = e.getTransform().getBaseValue().consolidate();


Mathias FATENE wrote:
 > Hi Frederick,
 > I would work with :
 > SVGDoc.getElementById("First").getAttribute("transform").split(" ")[1]
 > of course, must choose the best split character.
 >
 > But getCTM is better for giving you all the transformation informations.

I'm going to follow up on both suggestions.

Gary

Gary Frederick wrote:

I am trying to get the values in the translate on a <g> element with JavaScript. How do I do that?

Gary

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd";>
<svg width="24cm" height="8cm" viewBox="0 0 1200 400"
      onload="init(evt)"
     xmlns="http://www.w3.org/2000/svg"; version="1.1">
  <desc>Example rect02 - rounded rectangles</desc>
  <script type="text/ecmascript">
    <![CDATA[
      var svgns = "http://www.w3.org/2000/svg";;
      var SVGDoc;

function init(evt) {
// Get the Document
SVGDoc = evt.getTarget().getOwnerDocument();
alert('SVGDoc.getElementById("First") ='+SVGDoc.getElementById("First"));
/*


alert('SVGDoc.getElementById("First").transform.baseVal.numberOfItems ='

+SVGDoc.getElementById("First").transform.baseVal.numberOfItems);

alert('SVGDoc.getElementById("First").transform.baseVal.getItem(0).type ='

+SVGDoc.getElementById("First").transform.baseVal.getItem(0).type);


alert('SVGDoc.getElementById("First").transform.baseVal.getItem(0).matrix ='


+SVGDoc.getElementById("First").transform.baseVal.getItem(0).matrix);


alert('SVGDoc.getElementById("Second").transform.baseVal.numberOfItems ='


+SVGDoc.getElementById("Second").transform.baseVal.numberOfItems);

alert('SVGDoc.getElementById("Second").transform.baseVal.getItem(0).type ='

+SVGDoc.getElementById("Second").transform.baseVal.getItem(0).type);


alert('SVGDoc.getElementById("Second").transform.baseVal.getItem(0).matrix ='


+SVGDoc.getElementById("Second").transform.baseVal.getItem(0).matrix);
        */
       }
     ]]>
   </script>

<!-- Show outline of canvas using 'rect' element -->
  <rect x="1" y="1" width="1198" height="398"
        fill="none" stroke="blue" stroke-width="2"/>
  <g id="First" transform="translate(0 0)">
    <rect x="100" y="100" width="400" height="200" rx="50"
          fill="green" />
  </g>
  <g id="Second" transform="translate(700 210) rotate(-30)">
    <rect x="0" y="0" width="400" height="200" rx="50"
          fill="none" stroke="purple" stroke-width="30" />
  </g>
</svg>


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to