Some notes on exchanging code snippets (was: Re: [cairo] Re: How to use clipping?)

Carl Worth cworth at east.isi.edu
Tue Aug 3 12:02:03 PDT 2004


On Tue, 03 Aug 2004 14:48:56 -0400, Carl Worth wrote:
> Your code actually looks just fine [*].

Heh, I forgot to add the footnote I had planned there.

-Carl

[*] Sending little snippets of code around for test cases can be
tricky. Cairo holds lots of graphics state, and sometimes seemingly
irrelevant pieces of that state can be significant. Or, I've had cases
where users sent me test cases with variables in them (width, height,
angle), and when I made up values for the variables, I didn't get the
same results as the user.

So, what would help is if we could exchange test cases that all live
within a common environment. Fortunately, Øyvind Kolås has created
something like that within the cairo-demo/cairo_snippets module.

For example, I replicated your test case within cairo_snippets with the
following code:

	cairo_new_path (cr);
	cairo_move_to (cr, .25, .25);
	cairo_line_to (cr, .25, .75);
	cairo_line_to (cr, .75, .75);
	cairo_line_to (cr, .75, .25);
	cairo_line_to (cr, .25, .25);
	cairo_close_path (cr);

	cairo_clip (cr);

	cairo_move_to (cr, 0, 0);
	cairo_line_to (cr, 1, 1);
	cairo_stroke (cr);

You can just take that code, drop it in to some_file.cairo in the
cairo_snippets directory, and then after "make pngs", you will have
some_file.png and we can have good confidence that we'll get the same
results.

Some things about the snippets environment could still be improved. It
would be nice if it wouldn't re-generate a whole bunch of images when I
just change one snippet. Maybe it should also generate only the PNG
stuff by default, and require other make targets to get at the other
things.

But those are minor issues, so I do encourage people to try to replicate
bugs and such within cairo_snippets before sending code to the list.

Thanks,

-Carl





More information about the cairo mailing list