mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-05 17:44:55 -06:00
New PainterExamples
git-svn-id: svn://ultimatepp.org/upp/trunk@782 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
60c1b1dd3f
commit
a61c4c4e80
6 changed files with 107 additions and 9 deletions
37
examples/PainterExamples/Image.cpp
Normal file
37
examples/PainterExamples/Image.cpp
Normal file
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ uses
|
|||
file
|
||||
Examples.h,
|
||||
main.cpp,
|
||||
Image.cpp,
|
||||
Lion.cpp,
|
||||
Pythagoras.cpp,
|
||||
Spiral.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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue