struct Arc : Shape {
Arc(Point p, int ww, int hh, int a_start, int a_end) // center, min, and max distance from center
:w(ww), h(hh), arc_start(a_start), arc_end(a_end) { add(Point(p.x-ww,p.y-hh)); }
void draw_lines() const;
Point center() const { return Point(point(0).x+w,point(0).y+h); }
Point focus1() const {
if (h<=w)// foci are on the x-axis:
return Point(center().x+int(sqrt(double(w*w-h*h))),center().y);
else // foci are on the y-axis:
return Point(center().x,center().y+int(sqrt(double(h*h-w*w))));
}
Point focus2() const {
if (h<=w)
return Point(center().x-int(sqrt(double(w*w-h*h))),center().y);
else
return Point(center().x,center().y-int(sqrt(double(h*h-w*w))));
}
//Point focus2() const { return Point(center().x-int(sqrt(double(abs(w*w-h*h)))),center().y); }
void set_major(int ww) { set_point(0,Point(center().x-ww,center().y-h)); w=ww; }
int major() const { return w; }
void set_minor(int hh) { set_point(0,Point(center().x-w,center().y-hh)); h=hh; }
int minor() const { return h; }
private:
int w;
int h;
int arc_start;
int arc_end;
};
Since no one else is picking this up, I'll take a stab. I'm not set up to compile with FLTK, so I can't help with that.
Remember that a rounded rectangle has quarter arcs at the corners. The focal point of the arc is, of course, the radius of the arc. Likewise, the distance of the edge lines from the corners is the radii of the arcs.