struct Circle : Shape
{
Circle(Point p, int rr) // center and radius
: r{rr}
{
add(Point{p.x - r, p.y - r}); // store top left corner
}
void draw_lines() const;
Point center() const // returns the actual center when you have a point stored in (the top left corner)
{
return {point(0).x + r, point(0).y + r};
// return Point(point(0).x + r, point(0).y + r); // same results with this format
}
int radius() const { return r; } // access the private data member r
void set_radius(int rr)
{
set_point(0, Point{center().x - rr, center().y - rr});
r = rr;
}
private:
int r;
};
void Circle::draw_lines() const
{
if (fill_color().visibility())
{ // fill
fl_color(fill_color().as_int());
fl_pie(point(0).x, point(0).y, r + r - 1, r + r - 1, 0, 360);
fl_color(color().as_int()); // reset color
}
if (color().visibility())
{
fl_color(color().as_int());
fl_arc(point(0).x, point(0).y, r + r, r + r, 0, 360);
}
}