Rethinking snippets a bit (was: Re: [cairo] Default line width ==
2.0?)
Carl Worth
cworth at cworth.org
Thu Jan 6 12:20:33 PST 2005
On Tue, 21 Sep 2004 08:35:34 +0100, Calum Robinson wrote:
> On 21 Sep 2004, at 07:16, Øyvind Kolås wrote:
>
> > Are you doing the same initialization that cairo_snippets is doing?
>
> Ahh - I just copied & pasted the main code from the web page. Thanks
> for pointing that out.
This incidents leads me to suspect that we should generate snippets
with a more standard cairo environment, (eg. without changing the
default transformation). People learning from the web pages can easily
get the wrong idea about how cairo coordinates works.
Øyvind, I know that you would much rather have your snippet code work
in a normalized user-space. But how about just putting the
normalization code at the top of each such snippet:
cairo_scale (cr, width, height);
That could help educate users quite well. I don't mind if the width
and height variables magically come from the snippets
environment. That shouldn't confuse anybody.
Oh, I guess you would have to set the line width too, and that starts
to add a fair amount of repeated clutter to the snippets. Maybe
something like:
snippets_normalize (cr, width, height);
that could scale and set line width. And then snippets_normalize could
be made available as a snippet with no output. Then, things like the
HTML snippet environment could even make snippets_normalize a link so
that people browsing could easily see what is going on.
As for the other decorative initialization in the snippets, (clearing
to opaque white, drawing a black frame). This makes sense if the
particular snippet environment needs it, (eg. frames to separate
multiple snippets). But I don't think the decorations should be within
the snippets boundaries, nor should these decorations be used for all
environments.
For example, I'd like the PNG snippets to have the default transparent
background in order to demonstrate how cairo can be used to make
transparent images.
-Carl
More information about the cairo
mailing list