Re: Real-time ellipse creation - invalid matrix (not invertible) exception

Carlos López González <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CAF52pz+m0cnPSLyhkqu7dhETSEw7d-45+5PA=aFU637qn8s1ow@mail.gmail.com>
I think that you have to restore after stroke, not before:

cr->set_source_rgb(1.0, 1.0, 1.0);
cr->fill_preserve();
cr->stroke();
cr->restore(); /// restore after stroke operation, not before


2012/8/23 Lockert Fredrick <[email protected]>

> Greetings,
>
> I'm having a bit of a problem with my gtkmm/cairo ellipse shape
> creation tool. It works as expected, until the mouse pointer is moved
> in a negative direction of the initial start location (x, y), which
> results in an invalid matrix exception. After studying the gimp
> ellipse creation code, I couldn't find anything "obvious", thus I was
> hoping that someone might be able to point me in the right direction.
>
> Full source: http://fureloka.com/files/dev/gtkmm/drawingprog/
>
> ==Ellipse shape creation code==
>
> double x = mPt0.x; // Initial mouse click x cord.
> double y = mPt0.y; // Initial mouse click y cord.
> double w = mPt1.x; // Real-time mouse pointer x cord.
> double h = mPt1.y; // Real-time mouse pointer y cord.
>
> x = floor(x);
> y = floor(y);
> w = ceil(w);
> h = ceil(h);
>
> double center_x = (x + w) / 2.0;
> double center_y = (y + h) / 2.0;
>
> double radius_x = (w - x) / 2.0;
> double radius_y = (h - y) / 2.0;
>
> cr->save();
> cr->translate(center_x, center_y);
> cr->scale(radius_x, radius_y);
> cr->arc(0.0, 0.0, 1.0, 0.0, 2 * M_PI);
> cr->set_source_rgb(1.0, 1.0, 1.0);
> cr->fill_preserve();
> cr->restore();
> cr->stroke();
>
>
> As always, any help is highly appreciated!
>
> Cheers,
> Fredrick
> --
> cairo mailing list
> [email protected]
> http://lists.cairographics.org/mailman/listinfo/cairo
>



-- 
Carlos
http://synfig.org

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.