diff --git a/examples/PainterExamples/Big.cpp b/examples/PainterExamples/Big.cpp index 3a8ce6e30..db8a759e9 100644 --- a/examples/PainterExamples/Big.cpp +++ b/examples/PainterExamples/Big.cpp @@ -1,51 +1,51 @@ -#include "Examples.h" - -#ifndef _DEBUG - -void Big(Painter& sw) -{ - int n = 0; - double sgn = 1; - for(double r = 400; r > 5; r -= 3) { - for(double i = 0; i < 400; i++) { - Pointf p = Polar(sgn * i * M_2PI / 400) * r + Pointf(400, 400); - if(i) - sw.Line(p); - else - sw.Move(p); - sw.Line(Polar(sgn * (i * M_2PI / 400 + M_2PI / 800)) * (r - 6) + Pointf(400, 400)); - n += 2; - } - sw.Close(); - sgn = -sgn; - } - sw.Fill(Black()); - sw.Text(0, 0, "Elements: " + AsString(n), Arial(20)).Fill(Blue()); -} - -void BigStroke(Painter& sw) -{ - int n = 0; - double r = 400; - int i = 0; - while(r > 5) { - Pointf p = Polar(i * M_2PI / 400) * r + Pointf(400, 400); - if(i) - sw.Line(p); - else - sw.Move(p); - sw.Line(Polar((i * M_2PI / 400 + M_2PI / 800)) * (r - 3) + Pointf(400, 400)); - n += 2; - r = r - 0.01; - i++; - } - sw.Stroke(1, Black()); - sw.Text(0, 0, "Elements: " + AsString(n), Arial(20)).Fill(Blue()); -} - -INITBLOCK { - RegisterExample("Really Big Polygon", Big); - RegisterExample("Really Big Stroke", BigStroke); -} - -#endif \ No newline at end of file +#include "Examples.h" + +#ifndef _DEBUG + +void Big(Painter& sw) +{ + int n = 0; + double sgn = 1; + for(double r = 400; r > 5; r -= 3) { + for(double i = 0; i < 400; i++) { + Pointf p = Polar(sgn * i * M_2PI / 400) * r + Pointf(400, 400); + if(i) + sw.Line(p); + else + sw.Move(p); + sw.Line(Polar(sgn * (i * M_2PI / 400 + M_2PI / 800)) * (r - 6) + Pointf(400, 400)); + n += 2; + } + sw.Close(); + sgn = -sgn; + } + sw.Fill(Black()); + sw.Text(0, 0, "Elements: " + AsString(n), Arial(20)).Fill(Blue()); +} + +void BigStroke(Painter& sw) +{ + int n = 0; + double r = 400; + int i = 0; + while(r > 5) { + Pointf p = Polar(i * M_2PI / 400) * r + Pointf(400, 400); + if(i) + sw.Line(p); + else + sw.Move(p); + sw.Line(Polar((i * M_2PI / 400 + M_2PI / 800)) * (r - 3) + Pointf(400, 400)); + n += 2; + r = r - 0.01; + i++; + } + sw.Stroke(1, Black()); + sw.Text(0, 0, "Elements: " + AsString(n), Arial(20)).Fill(Blue()); +} + +INITBLOCK { + RegisterExample("Really Big Polygon", Big); + RegisterExample("Really Big Stroke", BigStroke); +} + +#endif diff --git a/examples/PainterExamples/PainterExamples.upp b/examples/PainterExamples/PainterExamples.upp index 2bcef0c91..59866f362 100644 --- a/examples/PainterExamples/PainterExamples.upp +++ b/examples/PainterExamples/PainterExamples.upp @@ -1,4 +1,4 @@ -description "Antialiased renderer class, Painter, examples, version 2.0"; +description "Antialiased renderer class, Painter, examples, version 2.0\377"; uses CtrlLib, @@ -31,11 +31,13 @@ file Arc.cpp, ThinLine.cpp, Shapes.cpp, + PolyPoly.cpp, Big.cpp, Examples.lay, Test.iml; mainconfig "" = "GUI", - "" = "GUI SSE2"; + "" = "GUI SSE2", + "" = "GUI .NOGTK"; diff --git a/examples/PainterExamples/PolyPoly.cpp b/examples/PainterExamples/PolyPoly.cpp new file mode 100644 index 000000000..e2dc28f6a --- /dev/null +++ b/examples/PainterExamples/PolyPoly.cpp @@ -0,0 +1,46 @@ +#include "Examples.h" + +void PolyPolyPolygon(Painter& sw) +{ + Point points[12][2][4]; + int subpolygon_counts[12][2]; + int disjunct_counts[12]; + Point lpoints[12][5]; + int lcounts[12][2]; + Pointf center(400, 300); + static const double out_delta = 2 * M_PI / 24; + static const double in_delta = 2 * M_PI / 48; + for(int i = 0; i < 12; i++) { + double angle = i * 2 * M_PI / 12; + points[i][0][0] = Polar(center, 200, angle); + points[i][0][1] = Polar(center, 120, angle - out_delta); + points[i][0][2] = Polar(center, 40, angle); + points[i][0][3] = Polar(center, 120, angle + out_delta); + points[i][1][0] = Polar(center, 160, angle); + points[i][1][1] = Polar(center, 120, angle + in_delta); + points[i][1][2] = Polar(center, 80, angle); + points[i][1][3] = Polar(center, 120, angle - in_delta); + subpolygon_counts[i][0] = 4; + subpolygon_counts[i][1] = 4; + disjunct_counts[i] = subpolygon_counts[i][0] + subpolygon_counts[i][1]; + + lpoints[i][0] = Polar(center, 260, angle + in_delta); + lpoints[i][1] = Polar(center, 230, angle); + lpoints[i][2] = Polar(center, 260, angle - in_delta); + lcounts[i][0] = 3; + lpoints[i][3] = Polar(center, 280, angle + in_delta); + lpoints[i][4] = Polar(center, 280, angle - in_delta); + lcounts[i][1] = 2; + } + sw.DrawPolyPolyPolygon(points[0][0], sizeof(points) / sizeof(Point), + subpolygon_counts[0], sizeof(subpolygon_counts) / sizeof(int), + disjunct_counts, sizeof(disjunct_counts) / sizeof(int), + LtBlue(), 4, LtRed(), I64(0xF0F0F0F00F0F0F0F)); + sw.DrawPolyPolyline(lpoints[0], sizeof(lpoints) / sizeof(Point), + lcounts[0], sizeof(lcounts) / sizeof(int), + 4, Color(0, 192, 0)); +} + +INITBLOCK { + RegisterExample("PolyPolyPolygon", PolyPolyPolygon); +} diff --git a/examples/PainterExamples/Shapes.cpp b/examples/PainterExamples/Shapes.cpp index a5b597120..972686353 100644 --- a/examples/PainterExamples/Shapes.cpp +++ b/examples/PainterExamples/Shapes.cpp @@ -1,7 +1,5 @@ #include "Examples.h" -#include "Examples.h" - void RoundedRect(Painter& sw) { sw.RoundedRectangle(100, 100, 400, 200, 20).Stroke(2, Black());