Pages

05 November, 2014

Cleaning up SVG `transform="translate(dx,dy)"` in Inkscape

I use SVGs in Inkscape and some JavaScript magic to create all my slides for talks and presentations and show them using Firefox or Chrome. Therefore, in Inkscape I draw rectangles on a separate layer to mark the view of each slides. All content goes to the second layer. My JavaScript -- actually it is some awesome CoffeeScript -- then uses the transform attribute to control the current view and the flow of the slides. However, sometimes Inkscape already sets an transform on some of the rectangles, e.g., when copying slides from previous presentations. These transforms interfere with my script.

Here is the trick how to remove them:
  1. Group the rectangles (Ctrl+G).
  2. Ungroup the group (Ctrl+Shift+G).
Inkscape will then recompute the x and y attributes, incorporating the translate(dx,dy) defined in the transform attribute. Afterwards, the transform will then be removed.

PS: If I find the time to cleanup my presentation script, I will open-source it on Github.

No comments: