Archive for September, 2009

Krita forum: Communicate

Monday, September 28th, 2009

We need the place where our users can meet. The place where the artists can share their artworks and tips&trick for Krita usage. Gimpers have their GimpTalk. Blender users have their blenderartists. Krita has it’s new Krita forum! Mailing-lists are cool, but not so much among users. Krita has it’s hidden mailing list here but the topic is usually development. Krita used to be called kimageshop.

Krita

We thought we will start the separate forum on krita2d.org (old not-up-to-date website) or we would go for KDE Forum and do what amaro(c)kers did with with their forum. We decided to go with KDE Forum for two main reasons:

  • it is a cool team, the KDE forum..and working with them was pleasure for me
  • we don’t have enough people to handle forum (it requires to code features, moderate, fight spam, etc. ) and Krita developers want to focus on developing Krita

Thank you, KDE Forum team!

Our forum is small and we hope it will grow and we will add more interesting subforums like those on the mentioned forums.

So now go and enjoy the new Krita forum. Post your artworks, ask how to use Krita, share and get Krita related news!

How to render outlines in Qt?

Monday, September 21st, 2009

I have seen some approaches how to paint tool outlines in KDE/Qt apps. We draw two types of outline in Krita:

* When you want to draw a line with line tool, you want to see the preview of the line. If you want to draw rectangle or ellipse or any shape in Krita, you also get the preview. Call this tool outline.

* When you paint with some brush in Krita, you need to see the position of the brush. You can have a cursor or the shape of the brush. That way you can see the preview of the brush borders. These shapes can be complicated. You can have brush shapes like big vector flower or something.

RasterOP_XOR

So far we used black lines for outlines in Krita2. It has big problem. You can’t see black line in black background, can you? So I wanted to resurrect XOR from Qt3 times in Krita. It has been also older regression. XOR has been removed, but it is somehow back. You can set QPainter to composite mode RasterOp_XOR. The disadvantage is that you can’t have anti-aliased lines with it. I solved this with CompositionMode_Exclusion. That one is similar to XOR. But that one does not work if you render on X11. You have to use QImage as buffer for your widget. So I added the QImage as buffer to our Arthur canvas (we also have OpenGL canvas, but we support both of them of course) and that way it worked.

Then thanks to C. Boemann showed me that it is not the solution. There are colors which make the outline invisible. When you use some colors as outline color(e.g. 128,255,128) and you have background RGB(127,127,127), the outline is invisible. This hidden problem is CompositeMode_Exclusion. But not in the RasterOp_XOR. That outline color (128,255,128) is not selected by random but by old bug report from Gimp. The selected color XORed to image is always contrast enough so it does not hide itself. So CompositeMode_Exclusion does not solve our problem, it just moves it away. We decided to use RasterOp_XOR so far. Outlines are not anti-aliased, but at least it does not hide itself. If you use OpenGL canvas in Krita, also XOR mode is used but lines are anti-aliased — we use OpenGL code for that. I wrote that piece of code through GSoC as you may remember..

We tried to paint outline 3px wide: semi-transparent black line 3px wide and white line 1px in between. That one may work but it looses some pixel precision in same use-cases. In a perfect world outline should be 1px wide — at least in pixel&image editing or painting app like Krita, Gimp..

What do you use to paint tool outline when you want pixel precision? And how do you paint outlines when the pixel precision is not important?Altering two colors looks usually too ugly :( At least for me..

The most nicer result I found is Inkscape. Inkscape uses some composition which makes it work on every color too. This was found in discussion what is Photoshop doing. When underlying pixel is bright enough, use dark color. If the underlying pixel is dark too much, use bright color? Maybe Inkscape uses also XOR with some color…I did not find out.
Write custom composite operation for Qt would be solution?

Zoom tool in Inkscape