[cairo] Real-time ellipse creation - invalid matrix (not invertible) exception
Carlos López González
genetita at gmail.com
Thu Aug 23 01:56:33 PDT 2012
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 <lockert.fredrick at gmail.com>
> 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
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
--
Carlos
http://synfig.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120823/ec2498ad/attachment-0001.html>
More information about the cairo
mailing list