diff --git a/examples/PainterExamples/Image.cpp b/examples/PainterExamples/Image.cpp new file mode 100644 index 000000000..e0984679e --- /dev/null +++ b/examples/PainterExamples/Image.cpp @@ -0,0 +1,37 @@ +#include "Examples.h" + + +void ImageExact(Painter& sw) +{ + sw.Rectangle(10, 10, 1000, 600) + .Fill(TestImg::test(), 100, 100, 500, 100) + .Stroke(2, Black()); +} + +void ImageReflect(Painter& sw) +{ + sw.Rectangle(10, 10, 1000, 600) + .Fill(TestImg::test(), 100, 100, 500, 100, FILL_REFLECT) + .Stroke(2, Black()); +} + +void ImagePad(Painter& sw) +{ + sw.Rectangle(10, 10, 1000, 600) + .Fill(TestImg::test(), 100, 100, 500, 100, FILL_PAD) + .Stroke(2, Black()); +} + +void ImageRepeat(Painter& sw) +{ + sw.Rectangle(10, 10, 1000, 600) + .Fill(TestImg::test(), 100, 100, 500, 100, FILL_REPEAT) + .Stroke(2, Black()); +} + +INITBLOCK { + RegisterExample("Image fill exact", ImageExact); + RegisterExample("Image fill reflect", ImageReflect); + RegisterExample("Image fill pad", ImagePad); + RegisterExample("Image fill repeat", ImageRepeat); +} diff --git a/examples/PainterExamples/Lion.cpp b/examples/PainterExamples/Lion.cpp index e05eb4093..6eb95eec7 100644 --- a/examples/PainterExamples/Lion.cpp +++ b/examples/PainterExamples/Lion.cpp @@ -202,8 +202,26 @@ void PaintLion(Painter& sw) } } sw.Fill(color); + + String txt = "U++ Painter"; + Font fnt = Roman(180).Bold(); + Size tsz = GetTextSize(txt, fnt); + sw.Text(0.5, 400.5, txt, fnt) + .Fill(TestImg::test(), 0, 400, 500, 400, FILL_REFLECT) + .Stroke(5, 0, 500, Blue(), tsz.cx, 500, LtRed()) + .Stroke(1, White()); + + for(int i = 0; i < 10; i++) { + sw.Begin(); + sw.Opacity(1 - (i + 1) / 10.0); + sw.Translate(600, 200); + sw.Rotate(i / 10.0 * M_2PI); + sw.Rectangle(0, 0, 200, 500) + .Fill(TestImg::test(), 0, 0, 200, 0); + sw.End(); + } } INITBLOCK { - RegisterExample("Lion", PaintLion); + RegisterExample("U++ Painter", PaintLion); } diff --git a/examples/PainterExamples/PainterExamples.upp b/examples/PainterExamples/PainterExamples.upp index 26d5ca787..bbec14fa6 100644 --- a/examples/PainterExamples/PainterExamples.upp +++ b/examples/PainterExamples/PainterExamples.upp @@ -7,6 +7,7 @@ uses file Examples.h, main.cpp, + Image.cpp, Lion.cpp, Pythagoras.cpp, Spiral.cpp, diff --git a/examples/PainterExamples/Pythagoras.cpp b/examples/PainterExamples/Pythagoras.cpp index f1e7f2094..f45079d78 100644 --- a/examples/PainterExamples/Pythagoras.cpp +++ b/examples/PainterExamples/Pythagoras.cpp @@ -1,6 +1,6 @@ #include "Examples.h" -void DoRect(Painter &sw, double size) +void DoRect(Painter &sw, double size, bool image) { if(size < 1) return; @@ -9,18 +9,21 @@ void DoRect(Painter &sw, double size) sw.Line(0, size); sw.Line(size, size); sw.Line(size, 0); - sw.Fill(Blue()); + if(image) + sw.Fill(TestImg::test(), 0, 0, size, 0); + else + sw.Fill(Blue()); sw.Begin(); sw.Translate(0, size); sw.Rotate(M_PI/4.); - DoRect(sw, size / M_SQRT2); + DoRect(sw, size / M_SQRT2, image); sw.End(); sw.Begin(); sw.Translate(size / 2, 1.5 * size); sw.Rotate(-M_PI/4.); - DoRect(sw, size / M_SQRT2); + DoRect(sw, size / M_SQRT2, image); sw.End(); } @@ -29,10 +32,20 @@ void PythagorasTree(Painter& sw) sw.Begin(); sw.Translate(450, 700); sw.Scale(1, -1); - DoRect(sw, 160); + DoRect(sw, 160, false); + sw.End(); +} + +void PythagorasTreeImage(Painter& sw) +{ + sw.Begin(); + sw.Translate(450, 700); + sw.Scale(1, -1); + DoRect(sw, 160, true); sw.End(); } INITBLOCK { RegisterExample("Pythagoras tree", PythagorasTree); + RegisterExample("Pythagoras tree image", PythagorasTreeImage); } diff --git a/examples/PainterExamples/RadialFocus.cpp b/examples/PainterExamples/RadialFocus.cpp index 53f43aad2..08facf44d 100644 --- a/examples/PainterExamples/RadialFocus.cpp +++ b/examples/PainterExamples/RadialFocus.cpp @@ -7,6 +7,33 @@ void RadialFocus(Painter& sw) ; } +void RadialFocusPad(Painter& sw) +{ + sw.Rectangle(10, 10, 1000, 600) + .Fill(300, 300, White(), 400.5, 400.5, 200, LtBlue(), GRADIENT_PAD) + .Stroke(2, Black()) + ; +} + +void RadialFocusReflect(Painter& sw) +{ + sw.Rectangle(10, 10, 1000, 600) + .Fill(300, 300, White(), 400.5, 400.5, 200, LtBlue(), GRADIENT_REFLECT) + .Stroke(2, Black()) + ; +} + +void RadialFocusRepeat(Painter& sw) +{ + sw.Rectangle(10, 10, 1000, 600) + .Fill(300, 300, White(), 400.5, 400.5, 200, LtBlue(), GRADIENT_REPEAT) + .Stroke(2, Black()) + ; +} + INITBLOCK { RegisterExample("Radial gradient with focus", RadialFocus); + RegisterExample("Radial gradient with focus - PAD", RadialFocusPad); + RegisterExample("Radial gradient with focus - REFLECT", RadialFocusReflect); + RegisterExample("Radial gradient with focus - REPEAT", RadialFocusRepeat); } diff --git a/examples/PainterExamples/StrokeBug.cpp b/examples/PainterExamples/StrokeBug.cpp index c9091e61d..6010d4736 100644 --- a/examples/PainterExamples/StrokeBug.cpp +++ b/examples/PainterExamples/StrokeBug.cpp @@ -11,10 +11,12 @@ void StrokeBug(Painter& sw) sw.Translate(-300, 0); sw.Text(100, 100, txt, fnt) .Stroke(10, 100, 100, Blue(), 100 + tsz.cx, 100, LtRed()) - .Stroke(0.25, White()); // _DBG_ - sw.Path("M 100 100 L 200 100 L 180 90 L 180 120").Stroke(25, Blue()); + .Stroke(0.25, White()); + sw.Path("M 100 100 L 200 100 L 210 90 L 220 40 L 230 90 L 240 100 L 400 100") + .EvenOdd(true) + .Stroke(24, Blue()); } INITBLOCK { - RegisterExample("Stroke bug", StrokeBug); + RegisterExample("Stroke bug (fixed)", StrokeBug); }