Painter: Rectangle/RoundedRectangle/Ellipse/Circle convenience overloads

This commit is contained in:
Mirek Fidler 2025-04-11 09:05:50 +02:00
parent ce70b04aa8
commit d1070154f6
3 changed files with 32 additions and 6 deletions

View file

@ -284,11 +284,6 @@ Painter& Painter::Rectangle(double x, double y, double cx, double cy)
return Move(x, y).RelLine(cx, 0).RelLine(0, cy).RelLine(-cx, 0).Close();
}
Painter& Painter::RoundedRectangle(double x, double y, double cx, double cy, double r)
{
return RoundedRectangle(x, y, cx, cy, r, r);
}
Painter& Painter::RoundedRectangle(double x, double y, double cx, double cy, double rx, double ry)
{
ASSERT(rx >= 0 && ry >= 0);

View file

@ -335,10 +335,19 @@ public:
void Paint(const Painting& p);
Painter& Rectangle(double x, double y, double cx, double cy);
Painter& RoundedRectangle(double x, double y, double cx, double cy, double r);
Painter& Rectangle(const Rectf& r) { return Rectangle(r.left, r.top, r.Width(), r.Height()); }
Painter& Rectangle(Pointf p1, Pointf p2) { return Rectangle(Rectf(p1, p2)); }
Painter& RoundedRectangle(double x, double y, double cx, double cy, double r1, double r2);
Painter& RoundedRectangle(const Rectf& r, double r1, double r2) { return RoundedRectangle(r.left, r.top, r.Width(), r.Height(), r1, r2); }
Painter& RoundedRectangle(Pointf p1, Pointf p2, double r1, double r2) { return RoundedRectangle(Rectf(p1, p2), r1, r2); }
Painter& RoundedRectangle(double x, double y, double cx, double cy, double r) { return RoundedRectangle(x, y, cx, cy, r, r); }
Painter& RoundedRectangle(const Rectf& rc, double r) { return RoundedRectangle(rc, r, r); }
Painter& RoundedRectangle(Pointf p1, Pointf p2, double r) { return RoundedRectangle(p1, p2, r, r); }
Painter& Ellipse(double x, double y, double rx, double ry);
Painter& Ellipse(const Rectf& r) { return Ellipse(r.left, r.top, r.Width(), r.Height()); }
Painter& Ellipse(Pointf p1, Pointf p2) { return Ellipse(Rectf(p1, p2)); }
Painter& Circle(double x, double y, double r);
Painter& Circle(Pointf p, double r) { return Circle(p.x, p.y, r); }
Painter& RectPath(int x, int y, int cx, int cy);
Painter& RectPath(const Rect& r);

View file

@ -340,6 +340,10 @@ of them, advance between characters can be overriden with [%-*@3 dx].&]
[s5;:Upp`:`:Painter`:`:Rectangle`(double`,double`,double`,double`): Painter[@(0.0.255) `&
] [* Rectangle]([@(0.0.255) double] [*@3 x], [@(0.0.255) double] [*@3 y],
[@(0.0.255) double] [*@3 cx], [@(0.0.255) double] [*@3 cy])&]
[s5;:Upp`:`:Painter`:`:Rectangle`(const Rectf`&`): Painter[@(0.0.255) `&]
[* Rectangle]([@(0.0.255) const] Rectf[@(0.0.255) `&] [*@3 r])&]
[s5;:Upp`:`:Painter`:`:Rectangle`(Pointf`,Pointf`): Painter[@(0.0.255) `&]
[* Rectangle](Pointf [*@3 p1], Pointf [*@3 p2])&]
[s2;%% Convenience method that adds a rectangle to the path.&]
[s3; &]
[s4; &]
@ -351,6 +355,18 @@ inter[@(0.0.255) `&] [* RoundedRectangle]([@(0.0.255) double] [*@3 x],
ainter[@(0.0.255) `&] [* RoundedRectangle]([@(0.0.255) double] [*@3 x],
[@(0.0.255) double] [*@3 y], [@(0.0.255) double] [*@3 cx], [@(0.0.255) double]
[*@3 cy], [@(0.0.255) double] [*@3 rx], [@(0.0.255) double] [*@3 ry])&]
[s5;:Upp`:`:Painter`:`:RoundedRectangle`(const Rectf`&`,double`): Painter[@(0.0.255) `&
] [* RoundedRectangle]([@(0.0.255) const] Rectf[@(0.0.255) `&] [*@3 rc],
[@(0.0.255) double] [*@3 r])&]
[s5;:Upp`:`:Painter`:`:RoundedRectangle`(Pointf`,Pointf`,double`): Painter[@(0.0.255) `&
] [* RoundedRectangle](Pointf [*@3 p1], Pointf [*@3 p2], [@(0.0.255) double]
[*@3 r])&]
[s5;:Upp`:`:Painter`:`:RoundedRectangle`(const Rectf`&`,double`,double`): Painter[@(0.0.255) `&
] [* RoundedRectangle]([@(0.0.255) const] Rectf[@(0.0.255) `&] [*@3 r],
[@(0.0.255) double] [*@3 r1], [@(0.0.255) double] [*@3 r2])&]
[s5;:Upp`:`:Painter`:`:RoundedRectangle`(Pointf`,Pointf`,double`,double`): Painter[@(0.0.255) `&
] [* RoundedRectangle](Pointf [*@3 p1], Pointf [*@3 p2], [@(0.0.255) double]
[*@3 r1], [@(0.0.255) double] [*@3 r2])&]
[s2;%% Convenience method that adds rounded rectangle to the path.
[%-*@3 r] specifies the radius of circular corner, [%-*@3 rx] [%-*@3 ry]
radii of elliptical corners.&]
@ -359,12 +375,18 @@ radii of elliptical corners.&]
[s5;:Upp`:`:Painter`:`:Ellipse`(double`,double`,double`,double`): Painter[@(0.0.255) `&
] [* Ellipse]([@(0.0.255) double] [*@3 x], [@(0.0.255) double] [*@3 y],
[@(0.0.255) double] [*@3 rx], [@(0.0.255) double] [*@3 ry])&]
[s5;:Upp`:`:Painter`:`:Ellipse`(const Rectf`&`): Painter[@(0.0.255) `&]
[* Ellipse]([@(0.0.255) const] Rectf[@(0.0.255) `&] [*@3 r])&]
[s5;:Upp`:`:Painter`:`:Ellipse`(Pointf`,Pointf`): Painter[@(0.0.255) `&]
[* Ellipse](Pointf [*@3 p1], Pointf [*@3 p2])&]
[s2;%% Convenience method that adds ellipse to the path.&]
[s3; &]
[s4; &]
[s5;:Upp`:`:Painter`:`:Circle`(double`,double`,double`): Painter[@(0.0.255) `&]
[* Circle]([@(0.0.255) double] [*@3 x], [@(0.0.255) double] [*@3 y], [@(0.0.255) double]
[*@3 r])&]
[s5;:Upp`:`:Painter`:`:Circle`(Pointf`,double`): Painter[@(0.0.255) `&]
[* Circle](Pointf [*@3 p], [@(0.0.255) double] [*@3 r])&]
[s2;%% Convenience method that adds circle to the path.&]
[s3; &]
[s4; &]