Rotation of the Canvas

We talked in Berlin at the KOffice Sprint about my Google Summer Of Code proposal and we decided to start with feature “Rotation of the Canvas”.The use-case is that you can rotate canvas in Krita according the rotation of your tablet. Basiclly in three dimensions. Also you can rotate the canvas for better orientation when the 3D brush will appear in Krita.

Krita Canvas Rotation glitch

First step for canvas rotation was drawing some UML diagram and get the idea how it looks in Krita and in KOffice libs (flake). I used Umbrello for KDE4. I really like the feature which import classes from C++ code. That’s nice. It is quite stable but has some issues here and there. I reported two bugs.

We want to support rotation of the canvas for both OpenGL-based canvas and QPainter-based canvas. There is already some nice support in Qt for it.

Some steps I need to solve

Output requairements:

1. Krita renders the whole image (layers and colorspace) into QImage or QPixmap and then displays the result.
2. Let’s rotate the rendered image around center using QPainter and QTransform.
3. The canvas is bigger when it is rotated, so I need to change the size of the canvas
4. Zoom has to be taken into account (points, inch and pixels are present in the API).

Input requirements:

1. The coordinates that comes from canvas events has to be transformed into 2D coordinates properly.

It seems easy. But it is complicated much more then one would think.Integrate it into Krita is the biggest problem. Math issues like transformations are already done in Qt.

So first week I spent time to investigate all related classes, I investigated canvas in Karbon which in infinte and we discussed that it would be cool to have infinte canvas for Krita. I realized that it can’t be adopted from Karbon, because for Krita it is more complicated. And then I started to use git-svn as my work on Krita Cavnas could break some stuff in trunk and creating gsoc-canvas branch seems to be the solution. Git is nice so far.

I just produced one small fix. I would like to achieve something like this, but so far I’m very far from it :)

This entry was posted in Krita. Bookmark the permalink.

5 Responses to Rotation of the Canvas

  1. Zeke Connor says:

    Very nice mate. I love it ^_^. The only question I have is, what is the performance while doing this?

  2. LukasT says:

    So far I can’t tell as I just rotated the view and now I’m trying to solve problems that comes.

  3. David says:

    Nice feature you are working on.

    PaintTool SAI have been doing this for a while too, though just 2D.

  4. Dread Knight says:

    Holy cow! Really looking forward to this feature. Especially since linux sucks hard when it comes to tablet pc’s and It’s not very easy to rotate display correctly while still having a functional stylus/cursor.. there are some scripts, but those imply you’re a geek to set up that kind of stuff.

    Krita will have all sorts of kick ass feature, but it has very poor usability atm and it’s very confusing = not many artists will use/love it, despite it’s outstanding features. But I’ll try to help out regarding that… and hopefully things will change for the better.
    Keep up the good work!

  5. wind-rider says:


    nice work. Would it be an idea to use the SpaceNavigator as an optional device to manipulate the canvas? Currently it can be used for zooming in Krita.
    IIRC Boudewijn Rempt has one spare device for people who like to hack on Krita using it.


Leave a Reply