Loading ...
Sorry, an error occurred while loading the content.

Re: retrieve shapes coordinates / remove transformations

Expand Messages
  • Frank Bruder
    ... You can call the element s method getCTM() to retrieve the current transformation matrix resulting from all transformations on it and its ancestor
    Message 1 of 3 , Jun 8, 2009
    • 0 Attachment
      --- In svg-developers@yahoogroups.com, "johan.brelet" <johan.brelet@...> wrote:
      >
      > In fact I need to remove all transformations attributes (translate, rotate, ...) in SVG in order to retrieve shapes exact coordinates.
      >
      You can call the element's method getCTM() to retrieve the current transformation matrix resulting from all transformations on it and its ancestor elements. To apply that transformation you would in some cases have to convert basic shapes to paths. (A scaled and translated rectangle or ellipse is still an ellipse, but if rotated you need a path.) If you want to keep basic shapes as basic shapes whenever possible, there will be a lot of case distinctions to be done. All basic shapes can be converted to equivalent paths.

      When it comes to transforming paths, I have implemented this in the function transformPath in my paths.js at
      <http://frankbruder.fr.ohost.de/FeSVGDoc/>

      It uses some things defined in util.js, especially the function transformEllipse. Transforming ellipses (needed for ellipse, circle, and rect with rounded corners, as well as "a" commands in paths) with general matrizes is rather complicated. It requires calculating eigenvalues and eigenvectors. You probably won't want to figure the math out yourself, so use my code.


      Regards
      Frank
    Your message has been successfully submitted and would be delivered to recipients shortly.