Painter: Edge case stroker issue fixed

This commit is contained in:
Mirek Fidler 2025-12-02 00:16:55 +01:00
parent 14f2def2bb
commit 8a3540d497
8 changed files with 56 additions and 64 deletions

View file

@ -0,0 +1,9 @@
uses
CtrlLib;
file
main.cpp;
mainconfig
"" = "GUI";

View file

@ -0,0 +1,20 @@
#include <CtrlLib/CtrlLib.h>
#include <Painter/Painter.h>
using namespace Upp;
struct MyApp : public TopWindow {
void Paint(Draw& draw) override {
DrawPainter w(draw, GetSize());
w.Clear(White());
// w.Circle(1400 + 760, 750, 600).Stroke(150, Blue());
w.Scale(150);
DLOG("============================ HERE");
w.Circle(5, 5, 4).Stroke(1, Blue());
}
};
GUI_APP_MAIN
{
MyApp().Run();
}

View file

@ -2,20 +2,6 @@
using namespace Upp;
void RoundedRectangle(Painter& p, double x, double y, double cx, double cy, double rx, double ry)
{
ASSERT(rx >= 0 && ry >= 0);
if (cx < 0) { x += cx; cx = -cx;}
if (cy < 0) { y += cy; cy = -cy;}
p.Move(x + rx, y).Arc(x + rx, y + ry, rx, ry, -M_PI / 2, -M_PI / 2);
return;
p.Line(x, y + cy - ry)//.Arc(x + rx, y + cy - ry, rx, ry, M_PI, -M_PI / 2)
// .Line(x + cx - rx, y + cy)//.Arc(x + cx - rx, y + cy - ry, rx, ry, M_PI / 2, -M_PI / 2)
.Line(x + cx, y + ry)//.Arc(x + cx - rx, y + ry, rx, ry, 0, -M_PI / 2)
.Line(x + rx, y);
}
struct MyApp : public TopWindow {
void Paint(Draw& w) override {
DrawPainter p(w, GetSize());
@ -23,37 +9,10 @@ struct MyApp : public TopWindow {
p.Scale(22);
p.Translate(5, 5);
DLOG("===============");
// p.LineJoin(LINEJOIN_ROUND);
#if 1
p.RoundedRectangle(-2, -2, 100, 100, 5, 5);
// RoundedRectangle(p, -2, -2, 100, 100, 5, 5);
p.Stroke(5, Blue());
#endif
#if 1
DLOG("---------------");
p.Translate(20, 0);
p
.Move(3, -2)
.Line(3, -2)
.Line(2.4887790452444, -1.97418556365037)
.Line(1.99232560327025, -1.89841777096139)
.Line(1.51315294861739, -1.77520989647291)
.Line(1.05377435582567, -1.60707521472478)
.Line(0.616703099434949, -1.39652700025684)
.Line(0.204452453985074, -1.14607852760896)
.Line(-0.180464305984105, -0.858243071320971)
.Line(-0.535533905932737, -0.535533905932738)
.Line(-0.858243071320971, -0.180464305984106)
.Line(-1.14607852760896, 0.204452453985073)
.Line(-1.39652700025684, 0.616703099434948)
.Line(-1.60707521472478, 1.05377435582567)
.Line(-1.77520989647291, 1.51315294861739)
.Line(-1.89841777096139, 1.99232560327025)
.Line(-1.97418556365037, 2.4887790452444)
.Line(-2, 3)
.Line(-2, 3)
;
p.Stroke(5, Blue());
#endif
}
};

View file

@ -11,13 +11,11 @@ struct MyApp : public TopWindow {
p.Clear(White());
p.Scale(22);
DLOG("-----------------------------");
p.Move(10, 10);
p.Arc(10, 10, 0.1, M_PI, M_PI);
// p.RoundedRectangle(2, 2, 100, 100, 0.1)
// p.Move(10, 10);
// p.Arc(10, 10, 0.1, M_PI, M_PI);
p.RoundedRectangle(2, 2, 100, 100, 0.1);
p.Stroke(5, Blue());
// p.Stroke(0.1, Blue());
p.Circle(20, 20, 10).Stroke(1, Blue());
}
};