2010-07-23 3 Comments
It would be great to have a theming engine that exposes basic drawing operations to theme authors. Instead of having a number of options per widget, you would deal with primitives like lines, rectangles and gradient fills.
Let me just say that I know of 2 developers who are on it🙂
Now if you want to draw a button that way, it appears to be simple enough. Just a usually rounded rectangle with one or several outlines (stroked rectangles), with gradient fills per outline and one for the body. If you assume light straight from top, vertical gradient fills with 4 stops for the outlines are sufficient for a somewhat realistic look.
Not so if you assume lighting from the top left. What I would like to have for such a case is one gradient per outline, with 8 stops placed exactly between the segments (= curves in the corners and straight lines on the sides). Extra points for the ability to add stops between the 8 fixed ones.
In Inkscape, you have to take the rectangles apart to get to that level of control, making it rather laborious and inflexible, as you can’t change the corner radius in a single step anymore, afterwards.
Example construction of a button:
- Outlines. It would be most comfortable to define the corner radius once, for the outermost rectangle. It should be possible to add up to at least 4 outlines, defaulting to 1 px strokes and inset.
- For each outline, there should be the option to have 8 gradient stops between the segments. The implementation could treat the segments separately, each with a simple linear gradient, just like I had to construct it in Inkscape here.
- Just a vertical linear gradient fill for the body.
- Plus a horizontal fill with 34 % opacity. It should be possible to layer linear and radial fills, with alpha per gradient stop.
- A shadow. This button doesn’t gain much from it, but it illustrates that drawing and layering rectangles with offsets would be useful.
- A plain black label.
- Gradient fill for the label. This can reduce legibility, but if handled with care, it makes button and label appear more like a whole.
- Luxury feature: sunken or raised (see 9.) look for the label. I used a crude approach with stroked and offset duplicates here, which works only on small scale. A clever implementation would take the angle of the character stroke and the lighting direction into account to render a smooth surrounding.