drawing shapes with gimp
João asks “why, oh why can’t Gimp have a basic shape drawing tool?”. The answer is simple, because noone wrote one yet. There is really no other reason. We know very well that this is a major missing feature. All the workarounds that exist are just that, workarounds.
João then continues:
I’m not talking about full drawing support (that’s for Inkscape), but just some tool which will automatically do the “select-fill-shrink-cut” steps so the user don’t need to memorize it. That’d be very handy.
Select-Fill-Shrink is really not what I would suggest you do for drawing shapes. A better solution is to stroke the selection using Edit->Stroke Selection. Depending on the shape you are drawing, you will want to convert the selection to a Path and stroke that.
An alternative to abusing the selection tools is to use the GFig plug-in as found in Filters->Render. But really, there should be a tool for drawing basic shapes. The tool could be build on top of the vectors framework that is used by the path tool. Basic shapes like lines, rectangles and ellipses can be easily created using the GimpBezierStroke API. One or more of these bezier curves are collected in a GimpVectors object, which can be stroked using gimp_drawable_stroke_vectors(). This stroking is done with a paint tool or using libart. The results are a lot better than what you can achieve by fiddling with the selection. It also allows to give the user much more control about the stroke. To get an idea of the parameters that can be controlled, look at this earlier blog entry.
Since we can serialize GimpVectors into SVG and deserialize them and since we can also store all stroke parameters using the GimpConfig framework, we can easily store all the information that is needed to reproduce such a stroke. That makes it easy to save the shape information in XCF in a backward compatible way and it paves the way for editable stroke layers. These could be implemented similar to how the text tool implements text layers.
September 1st, 2005 at 9:36 am
Btw, its Bug: #65197
http://bugzilla.gnome.org/show_bug.cgi?id=65197
September 1st, 2005 at 10:13 am
There is a script to create some basic shapes (rectangles, ellipses, polygons, stars, …) as vectors:
http://registry.gimp.org/plugin?id=5050
Once you have them, it is easy to alter them – at least a lot more easy than creating them with the paths tool.
September 1st, 2005 at 11:39 am
It would be a lot easier to create such shapes from scripts if we would export the GimpBezierStroke API to the PDB. The API should be easily understood by script authors. It allows you to create shapes by using the commands move-to, line-to, conic-to, cubic-to and arc-to. Anyone who has ever looked at PostScript or SVG will find this familiar. Since it isn’t trivial to create perfect ellipsis using this API, there’s a convenience function for that: gimp-bezier-stroke-new-ellipse. We could add a couple more of these, for example for creating rectangles.
Now all we need is a motivated volunteer to implement this. The relevant bug-report (which covers a bit more than what I mentioned here) is http://bugzilla.gnome.org/show_bug.cgi?id=129598
October 12th, 2005 at 1:33 pm
Is this something you want to work on? I have never felt a real need for yet another shape tool. The selection tools, Gfig and the path tool may not be perfect, they are good enough for simple shapes.
When they don’t suffice, there’s always Inkscape.
The biggest question for me is: which app do I use for compositing once I’ve got all the bitmap and vector elements ready?
October 14th, 2005 at 10:35 am
Me? No. I have so many things to finish for 2.4 and so little free time. But I hope that someone else will find this an interesting challenge and give it a try.