'bug' in chapter 15 of "programming in gtkmm" book



Under Chapter 15 The Drawing Area Widget,
the book gives this:

context->save();
context->translate(x, y);
context->scale(width / 2.0, height / 2.0);
context->arc(0.0, 0.0, 1.0, 0.0, 2 * M_PI);
context->restore();

to draw an ellipse in the box given by |x|, |y|, |width|, |height.|
|But, the centre of the ellipse is
the corner (x,y) rather than the
centre of the box.

To get it right, either change the translation, like this:
|
context->translate(x + width/2., y + height/2.);

or change the center, like this:

context->arc(0.5, 0.5, 1.0, 0.0, 2 * M_PI);


BTW, thanks for gtkmm and its docs.
jaidi

||



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]