Starting the FlowPaint project

One of my long term goals is to create a good paint program. I have several features that I'd like to see in a paint program, but that none of the current ones have.

I have some code for a half started one in the scratchpad directory of Skycastle, but now I went ahead and created a separate project for it. As usual, the hardest thing is to come up with a name - FlowPaint is refering to the state of flow that happens when you are immersed in painting - the application should support the workflow, instead of interrupting it.

You can find the development site of FlowPaint on Google Code.


Among other things, I want to render brush strokes as continuous textured areas, instead of repeatedly stamping a brush outline at short intervals along the stroke path like most existing paint programs do.

Here's the result of an evenings prototyping with Scala:


The stroke segment is defined by a start and endpoint, and the brush angle at the start and end. The renderer loops through the pixels to render, and calculates the position along the brush path, and the distance from the center of the path for each pixel, and then uses those values to query the brush implementation for a value. In this case the test brush returns a gradient to white towards the edges of the brush, and a gradient from red to yellow along the path of the brush. But it's also easy to write a brush implementation that instead uses a texture instead of a gradient to determine the color for each pixel. This opens up a lot of possibilities for the artist to produce complex patterns easily.

The prototype shows that the basic stroke segment rendering algorithm works, but performance is still a possible issue (the application will need to render a lot of segments fairly quickly, and re-render a part of the entire image when it is zoomed or panned significantly). A further spike to test out more optimized ways of rendering is likely needed (I scrapped my earlier plans for using 3D rendering, as render to texture isn't supported on the Intal graphics card on my tablet PC, and it would have caused a lot of trouble anyway).


Scala was very nice to work with. The prototype uses 9 small helper classes for things like Points, Lines, Brushes, etc. Often these are just one line in Scala. In Java each of these would have required an own file, and a lot of broilerplate accessories and constructor parameters, probably around 50 lines per file, including blank lines and comment lines. With Scala I can focus on thinking about the algorithm instead (the whole prototype is around 200 lines now, including blanklines and a few comments). I'll definitely continue using Scala for FlowPaint and future projects.

0 comments :: Starting the FlowPaint project