[cairo] Zero matrix transformation

Daniel Kraft d at domob.eu
Wed Mar 19 05:22:10 PDT 2008


Hi,

I just set-up git cairo and pixman and was playing around a bit with it. 
  On the GSoC ideas page there's one item:

Fix cairo so that a degenerate matrix draws nothing rather than 
triggering an error state. That is: cairo_scale (cr, 0, 0); should not 
cause an error, (though maybe it shouldn't actually draw nothing for 
painting an infinite source pattern---compute the average color for a 
surface-based source pattern perhaps?).

I tried to reproduce this, but for me (using the hello-program from the 
FAQ with this scale-statement added) this seems to work.  Using numbers 
between 0 and 1, the writing becomes smaller as I would expect; for 
using 0, nothing is drawn, as the item states as desired behaviour.

Did I understand something wrong, did my test not trigger the error for 
some reason, is this already done...?  I'd like to start working on 
cairo a bit to make experiences, and this looked not too hard.  If you 
have any other suggestions, I'd be happy to hear from you!

My test program:

#include <cairo.h>

int
main (int argc, char *argv[])
{
         cairo_surface_t *surface;
         cairo_t *cr;

         surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 240, 
80);
         cr = cairo_create (surface);

         cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, 
CAIRO_FONT_WEIGHT_BOLD);
         cairo_set_font_size (cr, 32.0);
         cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
         cairo_move_to (cr, 10.0, 50.0);
         cairo_scale(cr, 0., 0.);
         cairo_show_text (cr, "Hello, world");
         cairo_destroy (cr);
         cairo_surface_write_to_png (surface, "hello.png");
         cairo_surface_destroy (surface);

         return 0;
}

Thanks,
Daniel

-- 
Done:     Bar-Sam-Val-Wiz, Dwa-Elf-Hum-Orc, Cha-Law, Fem-Mal
Underway: Ran-Gno-Neu-Fem
To go:    Arc-Cav-Hea-Kni-Mon-Pri-Rog-Tou


More information about the cairo mailing list