28 Jul 2000 Talin   » (Journeyer)

After a frustrating day rebuilding my company's internal intranet server, I can have a relaxing evening programming... :-)

I am more and more impressed with Qt all the time. I've been writing a little mini "paint pad" widget for the Anima project. One of the primitives that I had hoped to implement eventually was rotated ellipses, in other words ellipses whose major axes are not aligned with the coordinate system. (These are especially useful in creating isometric tile sets.) Having struggled with this before, I know that there are basically three ways to draw a rotated ellipse:

  • Use a 2nd-order DDA, similar to Bresenham's algorithm, but for curves. Unfortunately, DDA's can get confused on very thin ellipses, and even go into an infinite loop.
  • Just compute the points directly using sin/cos. This works OK, but can have problems with quantization artifacts unless you get the spacing just right.
  • Approximate the ellipse with spline curves. This is probably the best overall solution.

So I noticed that Qt had a normal, axis-aligned ellipse primitive, like everyone else has. I also noticed that they also had a way to set up coordinate transformations (rotate, shear, etc.) into the QPainter object. "Big deal", I thought, "they're probably just running the input params through a transform matrix, the basic primitives are probably still axis aligned." Well, I had to check it out, and - surprise - the ellipse was actually rotated!

I've been leveraging the basic Qt drawing primitives to the max, and as a result I've been able to put together a complete painting widget in just a few days. It supports multiple brush sizes, can be extended with new stroke types and new transfer modes (such as colorize, brighten, etc.)

Since KIconEdit seems to be broken at the moment, I'm going to let the paint pad widget draw it's own icons. Gotta get that saving/loading function to work first...!

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!