SDraw alpha masks

git-svn-id: svn://ultimatepp.org/upp/trunk@743 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-01-13 23:48:02 +00:00
commit d0174106e6
55 changed files with 38656 additions and 83 deletions

View file

@ -436,6 +436,7 @@ void RadialGradient(ImageBuffer& ib, int cx, int cy, int r, RGBA c1, RGBA c2, in
}
}
*/
struct App : TopWindow {
Point p;
@ -449,74 +450,70 @@ struct App : TopWindow {
Size sz = GetSize();
ImageBuffer ib(sz);
Fill(~ib, White(), ib.GetLength());
SDraw sw(ib);
sw.Clear(White());
const char *txt = "This is just a test of alpha mask blending";
Size tsz = GetTextSize(txt, Roman(50).Italic());
// sw.Text(0, 0, txt, Roman(70))
// .Fill(Blue());
// sw.Arc(500, 500, 400, 400, 0, M_2PI).Clip();
// sw.Arc(700, 700, 400, 400, 0, M_2PI).Clip();
// for(int y = tsz.cy + 10; y < sz.cy; y += tsz.cy)
// sw.Text(10, y, txt, Roman(70))
// .Fill(Blue());
sw.Begin();
sw.BeginMask();
sw.Move(0, 0).Line(tsz.cx, 0).Line(tsz.cx, sz.cy).Line(0, sz.cy)
.Fill(0, 0, White(), tsz.cx, 0, Black());
sw.End();
sw.Text(0, 0, txt, Roman(50))
.Fill(Blue());
sw.End();
// sw.Text(500, 500, "Test", Arial(50)).Fill(Black());
sw.Begin();
sw.BeginMask();
sw.Move(0, 0).Line(tsz.cx, 0).Line(tsz.cx, sz.cy).Line(0, sz.cy)
.Fill(0, 0, Black(), tsz.cx, 0, White());
sw.End();
sw.Text(0, 0, txt, Roman(50).Italic())
.Fill(Red());
sw.End();
sw.Begin();
sw.BeginMask();
sw.Move(0, 0).Line(tsz.cx + 20, 0).Line(tsz.cx + 20, sz.cy + 20).Line(0, sz.cy + 20)
.Fill(tsz.cx / 2, tsz.cy + tsz.cx / 2, tsz.cx / 2, White(), Black());
sw.End();
for(int y = tsz.cy + 10; y < sz.cy; y += tsz.cy)
sw.Text(10, y, txt, Roman(50))
.Fill(Blue());
sw.End();
sw.Begin();
sw.BeginMask();
sw.Move(0, 0).Line(tsz.cx + 20, 0).Line(tsz.cx + 20, sz.cy + 20).Line(0, sz.cy + 20)
.Fill(tsz.cx / 2, tsz.cy + tsz.cx / 2, tsz.cx / 2, Black(), White());
sw.End();
for(int y = tsz.cy + 10; y < sz.cy; y += tsz.cy)
sw.Text(10, y, txt, Roman(50).Italic())
.Fill(Blue());
sw.End();
sw.Translate(0.5, 0.5);
sw.Move(10, tsz.cy).Line(tsz.cx + 20, tsz.cy)
.Line(tsz.cx + 20, tsz.cx + tsz.cy + 20).Line(10, tsz.cx + tsz.cy + 20)
.Close()
.Stroke(1, Cyan());
// RadialGradient(ib, 200, 200, 100, White(), Blue(), 150, 160);
SDraw sw(ib);
// sw.Translate(300, 300);
// sw.Scale(0.01 * p.x);
// sw.Text(0, 0, "HELLO WORLD!", Arial(300).Bold())
// .Fill(Gradient(50 * Blue(), Red()).Stop(0.4, Green()),
// 1000, 0, 1500, 0, GRADIENT_REFLECT);
// sw.Rotate(0.01 * p.y - M_PI);
sw.Text(500, 200, "Hello world!", Arial(400)).Fill(Black()).Fill(Black());
#if 0
sw.Move(0, 0).Line(3000, 0).Line(3000, 3000).Line(0, 3000)
.Fill(TestImg::test(), 800, 500, 1800, 800, 0
|FILL_PAD
|FILL_REPEAT
|FILL_FAST
|FILL_HREPEAT|FILL_VREFLECT
);
#endif
// sw.Text(500, 50, "HELLO WORLD!", Arial(300).Bold())
// .ColorStop(0.4, Green())
// .Fill(1000, 0, 50 * Blue(), 1500, 0, Red(), GRADIENT_REFLECT);
// sw.Arc(230, 200, 110, 100, 0, 2 * M_PI)
//.Fill((230 - 110) * 0.2, (200 - 100) * 0.4, 100, 110, 100,
// Color(200, 200, 200), Color(0, 0, 255));
// sw.Move(0, 0).Line(3000, 0).Line(3000, 3000).Line(0, 3000)
// .ColorStop(0.2, LtRed())
// .ColorStop(0.7, Yellow())
// .Fill(400, 400, 400, p.x, p.y, White(), Blue(), GRADIENT_REFLECT);
// .Fill(400, 400, 400, White(), Blue(), GRADIENT_REPEAT);
// .Fill(400, 400, 400, p.x, p.y, White(), Blue());
// sw.Opacity(0.5);
sw.Arc(500, 500, 100, 100, 0, M_2PI)
// .ColorStop(0.2, LtRed())
// .ColorStop(0.7, Yellow())
.Fill(500, 500, 100, p.x, p.y, White(), Blue());
// .Fill(200, 200, 100, 150, 160, White(), Blue());
// sw.Arc(200, 200, 100, 100, 0, M_2PI)
// ;
#if 0
sw.Arc(200, 200, 100, 100, 0, M_2PI)
.Fill(200, 200, 100, 150, 150, White(), Black())
.Opacity(0.3)
.Fill(100, 200, LtRed(), 300, 200, Blue())
;
#endif
sw.Arc(200, 200, 50, 50, 0, M_2PI)
.ColorStop(0.5, Color(0, 128, 128))
.Fill(200, 200, 50, Black(), White())
// .Fill(200, 200, 100, 150, 150, Black(), White())
.Stroke(1, Black())
;
sw.Arc(400, 200, 50, 50, 0, M_2PI)
.ColorStop(0.5, Color(0, 128, 128))
.Fill(400, 200, 50, 375, 175, Black(), White())
.Stroke(1, Black())
;
// PaintExample(sw);
sw.Rotate(0.05);
@ -534,7 +531,7 @@ struct App : TopWindow {
// PaintLion(NULL, &iw);
}
// w.DrawImage(500, 0, iw);
// w.DrawText(0, 0, AsString(gradient_t));
}
App() { Sizeable().Zoomable(); p = Point(0, 0); }
@ -588,3 +585,73 @@ GUI_APP_MAIN
#endif
App().Run();
}
#if 0
SDraw sw(ib);
// sw.Scale(1, 0.5);
// sw.Translate(300, 300);
// sw.Scale(0.01 * p.x);
// sw.Text(0, 0, "HELLO WORLD!", Arial(300).Bold())
// .Fill(Gradient(50 * Blue(), Red()).Stop(0.4, Green()),
// 1000, 0, 1500, 0, GRADIENT_REFLECT);
// sw.Rotate(0.01 * p.y - M_PI);
sw.Text(500, 200, "Hello world!", Arial(400)).Fill(Black()).Fill(Black());
#if 0
sw.Move(0, 0).Line(3000, 0).Line(3000, 3000).Line(0, 3000)
.Fill(TestImg::test(), 800, 500, 1800, 800, 0
|FILL_PAD
|FILL_REPEAT
|FILL_FAST
|FILL_HREPEAT|FILL_VREFLECT
);
#endif
// sw.Text(500, 50, "HELLO WORLD!", Arial(300).Bold())
// .ColorStop(0.4, Green())
// .Fill(1000, 0, 50 * Blue(), 1500, 0, Red(), GRADIENT_REFLECT);
// sw.Arc(230, 200, 110, 100, 0, 2 * M_PI)
//.Fill((230 - 110) * 0.2, (200 - 100) * 0.4, 100, 110, 100,
// Color(200, 200, 200), Color(0, 0, 255));
// sw.Move(0, 0).Line(3000, 0).Line(3000, 3000).Line(0, 3000)
// .ColorStop(0.2, LtRed())
// .ColorStop(0.7, Yellow())
// .Fill(400, 400, 400, p.x, p.y, White(), Blue(), GRADIENT_REFLECT);
// .Fill(400, 400, 400, White(), Blue(), GRADIENT_REPEAT);
// .Fill(400, 400, 400, p.x, p.y, White(), Blue());
// sw.Opacity(0.5);
// sw.Move(0, 0).Line(3000, 0).Line(3000, 3000).Line(0, 3000)
sw.Move(400, 400).Line(600, 400).Line(600, 600).Line(400, 600)
// sw.Arc(500, 500, 100, 100, 0, M_2PI)
.ColorStop(0.2, LtRed())
.ColorStop(0.7, Yellow())
.Fill(500, 500, 80, p.x, p.y, White(), Blue(), GRADIENT_REFLECT);
// .Fill(200, 200, 100, 150, 160, White(), Blue());
// sw.Arc(200, 200, 100, 100, 0, M_2PI)
// ;
#if 0
sw.Arc(200, 200, 100, 100, 0, M_2PI)
.Fill(200, 200, 100, 150, 150, White(), Black())
.Opacity(0.3)
.Fill(100, 200, LtRed(), 300, 200, Blue())
;
#endif
sw.Arc(200, 200, 50, 50, 0, M_2PI)
.ColorStop(0.5, Color(0, 128, 128))
.Fill(200, 200, 50, Black(), White())
// .Fill(200, 200, 100, 150, 150, Black(), White())
.Stroke(1, Black())
;
sw.Arc(400, 200, 50, 50, 0, M_2PI)
.ColorStop(0.5, Color(0, 128, 128))
.Fill(400, 200, 50, 375, 175, Black(), White())
.Stroke(1, Black())
;
#endif