Rotating Canvas

From Inkscape Wiki
Jump to navigation Jump to search

Being able to rotate the canvas while working on a drawing is a highly desirable feature. Unfortunately, most of Inkscape's code assumes a non-rotating canvas.

Basic Strategy

The Inkscape SPDesktop class's Geom::Affine _w2d variable defines the Window to Desktop coordinate transformation (and _d2w defines the inverse). In 0.92.x _w2d is limited to scaling. Rotating the canvas can be added to this variable. It might also be possible to add translation (to handle scrolling) as well.


  • Adapt current zooming code to work if _w2d includes a rotation.
    • ✔New function: SPDesktop::set_display_area() that takes as input:
      • The current transformation (_w2d).
      • A point on the drawing and a point on the screen which are to be aligned.
    • ✔All basic zooming functions can be handled as special cases of this new function.
    • ✔Update/replace all instances of set_display_area() to use new version.
    • Replace all instances of get_display_area() to handle rotated frame. Not needed?
  • ✔Add rotation functions that follows the zoom functions pattern.
  • Add GUI to set rotation.
    • Menu items with keyboard shortcuts.
    • On-screen editing tools using a class derived from SPCanvasItem.
    • Fix problems (see below).


  • ✔The tools (Rectangle, Path, etc.) seem to already work when _w2d includes a rotation.
  • On screen elements need to be transformed.
    • ✔Guides (already shown at correct angles but ends are in wrong places.
    • Grids
    • Bounding boxes (CtrlRect)
    • Page outline (CtrlRect)
    • Arrow handles for resize, skew, ...
  • ✔Scrolling needs to be adjusted.