[cairo] Questions about clipping

Enzo Ferrari eferrari at anastasis.it
Mon Feb 26 03:21:54 PST 2007


Behdad Esfahbod ha scritto:
> It shouldn't.  Can you attach a simple test program showing this?

My program is written in Delphi (pascal) and uses a wrapper to
libcairo-2.dll (1.2.6 version)
Anyway I don't think the problem is in the wrapper cause it
works in many cases.

I've extracted the list of cairo calls that throw
an exception ("invalid floating point operation")


    cairo_surface = cairo_win32_surface_create
       (<handle to a windows bitmap surface>);
    cr = cairo_create (cairo_surface);
    cairo_scale (cr, 600, 600);
    cairo_set_source_rgba (cr, 1, 1, 1, 1);
    cairo_paint (cr);

    // ELLIPSE n.1

    cairo_save (cr);
    cairo_translate (cr, 0.5, 0.31);
    cairo_scale (cr, 1, 0.77);
    cairo_arc (cr, 0, 0, 0.80, 0, M_PI*2);
    cairo_restore (cr);
    cairo_set_source_rgb (cr, 1, 1, 0);
    cairo_fill_preserve (cr);   // <------- THIS LINE WORKS CORRECTLY
    cairo_set_source_rgb (cr, 0, 0, 0);
    cairo_set_line_width (cr, 0.003);
    cairo_set_dash (cr, NULL, 0, 0);
    cairo_stroke (cr);

    // ELLIPSE n.2

    cairo_save (cr);
    cairo_translate (cr, 0.5 , 0.31);
    cairo_scale (cr, 1, 0.77);
    cairo_arc (cr, 0, 0, 0.90, 0, M_PI*2);
    cairo_restore (cr);
    cairo_set_source_rgb (cr, 1, 1, 0);
    cairo_fill_preserve (cr);   // <------- THIS LINE THROWS AN EXCEPTION
    cairo_set_source_rgb (cr, 0, 0, 0);
    cairo_set_line_width (cr, 0.003);
    cairo_set_dash (cr, NULL, 0, 0);
    cairo_stroke (cr);

    cairo_destroy (cr);

As you can see the operations made in ELLIPSE n.1 and the ones made in
ELLIPSE n.2 differs only for the third parameter of cairo_arc function
(0.80 --> 0.90)

Can someone try it?

Thanks in advance,
Enzo.

-- 
Enzo Ferrari
Sviluppo Software Didattico
Coop. Anastasis - Bologna
http://www.anastasis.it



More information about the cairo mailing list