Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Could you explain why you need to push and pop transformation state?</p> <p>In svg you don't really need to do that, the browsers do it for you. If you want a particular transform to apply to an element then just add a <a href="http://www.w3.org/TR/SVG11/coords.html#TransformAttribute" rel="nofollow">transform attribute</a> to it. You can make a transform apply to many elements by using <code>&lt;g&gt;</code> elements (in Raphaël there's <a href="http://raphaeljs.com/reference.html#Paper.set" rel="nofollow">Paper.set</a>, which can be used like a <code>&lt;g&gt;</code> element, and you have the <a href="http://raphaeljs.com/reference.html#Element.transform" rel="nofollow">Element.transform</a> method to set the transforms).</p> <p><strong>Update:</strong></p> <p><code>context.save()</code> - in svg terms this would be to take the current transformation matrix (CTM) of the element at a given time and storing it somewhere, in Raphaël I guess this might be <a href="http://raphaeljs.com/reference.html#Element.transform" rel="nofollow">Element.transform()</a> (I'm not 100% sure if it includes whole stack of transformations or not, anyway, in pure svg the CTM can be fetched via the <a href="http://www.w3.org/TR/SVG11/types.html#__svg__SVGLocatable__getCTM" rel="nofollow">getCTM()</a> method which is available on all elements). One way of doing this would be to insert a <code>&lt;g&gt;</code> element with the transformation you want.</p> <p><code>context.restore()</code> - in svg this would be equivalent to removing a transformation from the list of transforms, but note that in svg siblings don't "inherit" the transformation (this is unlike html5 canvas or OpenGL where the currently set matrix is just applied to anything you draw after setting the transform). If you want a transform to apply to many elements then you create a <code>&lt;g&gt;</code> which has the transformation that should apply to all the children of that element, and to restore you just insert elements to the parent of the <code>&lt;g&gt;</code> instead. Raphaël doesn't have any built-in support for the <code>&lt;g&gt;</code> element (unless you count Element.set, which is a similar concept), a guess for why Raphaël does this is that it's to prevent people from trying to do things like this since it becomes very easy to bloat the DOM without realizing it (remember, SVG is a <a href="http://en.wikipedia.org/wiki/Retained_mode" rel="nofollow">retained mode</a> graphics format, unlike canvas and OpenGL).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload