I think that you have to restore after stroke, not before:<br><br>cr->set_source_rgb(1.0, 1.0, 1.0);<br>
cr->fill_preserve();<br>
cr->stroke();<br>
cr->restore(); /// restore after stroke operation, not before<br>
<br><br><div class="gmail_quote">2012/8/23 Lockert Fredrick <span dir="ltr"><<a href="mailto:lockert.fredrick@gmail.com" target="_blank">lockert.fredrick@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Greetings,<br>
<br>
I'm having a bit of a problem with my gtkmm/cairo ellipse shape<br>
creation tool. It works as expected, until the mouse pointer is moved<br>
in a negative direction of the initial start location (x, y), which<br>
results in an invalid matrix exception. After studying the gimp<br>
ellipse creation code, I couldn't find anything "obvious", thus I was<br>
hoping that someone might be able to point me in the right direction.<br>
<br>
Full source: <a href="http://fureloka.com/files/dev/gtkmm/drawingprog/" target="_blank">http://fureloka.com/files/dev/gtkmm/drawingprog/</a><br>
<br>
==Ellipse shape creation code==<br>
<br>
double x = mPt0.x; // Initial mouse click x cord.<br>
double y = mPt0.y; // Initial mouse click y cord.<br>
double w = mPt1.x; // Real-time mouse pointer x cord.<br>
double h = mPt1.y; // Real-time mouse pointer y cord.<br>
<br>
x = floor(x);<br>
y = floor(y);<br>
w = ceil(w);<br>
h = ceil(h);<br>
<br>
double center_x = (x + w) / 2.0;<br>
double center_y = (y + h) / 2.0;<br>
<br>
double radius_x = (w - x) / 2.0;<br>
double radius_y = (h - y) / 2.0;<br>
<br>
cr->save();<br>
cr->translate(center_x, center_y);<br>
cr->scale(radius_x, radius_y);<br>
cr->arc(0.0, 0.0, 1.0, 0.0, 2 * M_PI);<br>
cr->set_source_rgb(1.0, 1.0, 1.0);<br>
cr->fill_preserve();<br>
cr->restore();<br>
cr->stroke();<br>
<br>
<br>
As always, any help is highly appreciated!<br>
<br>
Cheers,<br>
Fredrick<br>
<span class="HOEnZb"><font color="#888888">--<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>Carlos<br><a href="http://synfig.org" target="_blank">http://synfig.org</a><br><br>