Today we have the final pencils down for the Google Summer of Code 2012. It was a wonderful experience do this work along with an awesome team such as the Krita developers. So much learning, and yet so much to be learned, that only a summertime it's not enough.
Along the course of this project, I made some changes in many things, like the integrator, the particle implementation, mouse dynamics calculation and other features, which appeared while the job was advancing in its results. However, the initial functions related with the sand painting style were always the final purpose, so they endured.
I described some of the implementations we made so far and what is yet to be done. I put a few links to past blog posts that described some of the features developed in more detail.
What we have
The problems concerning the Pouring operation was made in this post. There are some things to do, but for now, I believe that the current state will do. The Pouring set some properties related to the grains, such as size, mass and friction, which modifies the way the spread operation work
|The brush settings widget: we have the brush settings and the grains settings. Most of them have a diference in the Pouring operation mode.|
Once we add grains in the canvas, we can Spread them like a regular sand painting technique. Initially we had some numerical errors related with the grains positions and velocities. To fix this problem was really hard but we accomplish good results without compromising performance.
I made a video of an experiment :
Note that the particles are not erased while spreading. Taking a closer look we see that the particles are painted in new positions, although some of them act a little out of the expected behaviour.
From the videos and images some of you could think that the brush works only in grayscale, but it does work in other color models :
We made strokes of the Pouring operation with different colors in each one.
After that, we did some Spread (the well defined white spaces) to show it working in the color grains. The main drawback in this Spread operation is the grain color handling. When we update the grains positions we repaint them using the current color (when putting a grain in a new position) and background color (when "erasing" the particle previous position). We can improve that by holding the color used in the Pouring operation inside the Particle class and deleting the previous position using a alpha channel painting.
What is missing
There are a few more things that were planed to be done, but I didn't have time to do it. Again, to the Spread operation work properly it took a very good effort so it could emulate the sand behaviour while the user painted using it.
As explained in this post, we divided the canvas in a number of grid cells so it could apply the Spread only in those which are under the mouse position.
However, the grains which are under the brush radius should have been spread as well. So one of the things to be done is the to extend the grid cell selection under the mouse radius, not only to the mouse position. There is also the posibility of customizing the grid size for user convenience: larger cells for faster computers, smaller cells for slower computers.
A missing feature is the mouse "particle" customization. The spreading is made by emulating a particle in the mouse position with the same size as the brush radius. However, the mass and friction for the brush are the same as the current configuration of the grain particles, so it's not a very user friendly setting scheme, since the grains settings is only, obviously, for the grains.
Another problem is when you save a document where you used the sand brush. When you load it, the particle positions are not retrieved, although we can use the created KisAnnotation to do so.
Well, now we wait for the evaluation. I tried to put a good documentation in the code so anyone can understand what is happening in each part of it. Although some things are missing, most of what was proposed was made
and the main features are working well. I need to do some more tweaks to make the brush more user friendly, but for now, the visual results are satisfying.
I really hope I can continue working in this brush in the next years so it can have a behaviour even more beffiting with the actual behaviour of sand painting. But we will make more plans when we are sure that everything went okay in the evaluation.
Until next time!