mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Painter 2.0 noaa
git-svn-id: svn://ultimatepp.org/upp/trunk@853 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
a5d3e14cc7
commit
c9f4311517
5 changed files with 47 additions and 5 deletions
|
|
@ -249,6 +249,16 @@ struct MaskFillerFilter : Rasterizer::Filler {
|
|||
void Set(Rasterizer::Filler *f, const byte *m) { t = f; mask = m; empty = full = 0; }
|
||||
};
|
||||
|
||||
struct NoAAFillerFilter : Rasterizer::Filler {
|
||||
Rasterizer::Filler *t;
|
||||
|
||||
void Start(int minx, int maxx);
|
||||
void Render(int val, int len);
|
||||
void Render(int val);
|
||||
|
||||
void Set(Rasterizer::Filler *f) { t = f; }
|
||||
};
|
||||
|
||||
Image MipMap(const Image& img);
|
||||
Image MakeMipMap(const Image& img, int level);
|
||||
|
||||
|
|
|
|||
|
|
@ -96,4 +96,19 @@ void SpanFiller::Render(int val, int len)
|
|||
AlphaBlendCover8(*t++, *s++, val);
|
||||
}
|
||||
|
||||
void NoAAFillerFilter::Start(int minx, int maxx)
|
||||
{
|
||||
t->Start(minx, maxx);
|
||||
}
|
||||
|
||||
void NoAAFillerFilter::Render(int val, int len)
|
||||
{
|
||||
t->Render(val < 128 ? 0 : 256, len);
|
||||
}
|
||||
|
||||
void NoAAFillerFilter::Render(int val)
|
||||
{
|
||||
t->Render(val < 128 ? 0 : 256);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ public:
|
|||
Painter& EvenOdd(bool evenodd = true);
|
||||
Painter& Dash(const Vector<double>& dash, double start);
|
||||
Painter& Dash(const char *dash, double start = 0);
|
||||
Painter& NoAA(bool noaa);
|
||||
Painter& NoAA(bool noaa = true);
|
||||
|
||||
Painter& Transform(const Xform2D& m);
|
||||
Painter& Translate(double x, double y);
|
||||
|
|
|
|||
|
|
@ -39,9 +39,10 @@ Buffer<ClipLine> BufferPainter::RenderPath(double width, SpanSource *ss, const R
|
|||
Pointf pos = Pointf(0, 0);
|
||||
int i = 0;
|
||||
Rasterizer::Filler *rg;
|
||||
SpanFiller span_filler;
|
||||
SolidFiller solid_filler;
|
||||
ClipFiller clip_filler(ib.GetWidth());
|
||||
SpanFiller span_filler;
|
||||
SolidFiller solid_filler;
|
||||
ClipFiller clip_filler(ib.GetWidth());
|
||||
NoAAFillerFilter noaa_filler;
|
||||
bool doclip = width == -2;
|
||||
if(doclip) {
|
||||
rg = &clip_filler;
|
||||
|
|
@ -60,7 +61,10 @@ Buffer<ClipLine> BufferPainter::RenderPath(double width, SpanSource *ss, const R
|
|||
solid_filler.c = Mul8(color, opacity);
|
||||
rg = &solid_filler;
|
||||
}
|
||||
|
||||
if(pathattr.noaa) {
|
||||
noaa_filler.Set(rg);
|
||||
rg = &noaa_filler;
|
||||
}
|
||||
for(;;) {
|
||||
if(i >= path.type.GetCount() || path.type[i] == DIV) {
|
||||
g->End();
|
||||
|
|
|
|||
|
|
@ -189,6 +189,18 @@ void PaintLion(Painter& sw)
|
|||
}
|
||||
}
|
||||
|
||||
void PaintLionNoAA(Painter& sw)
|
||||
{
|
||||
static Vector<ColorPolygon> l = Lion();
|
||||
for(int i = 0; i < l.GetCount(); i++) {
|
||||
Vector<Pointf>& p = l[i].point;
|
||||
sw.Move(p[0].x, p[0].y);
|
||||
for(int j = 1; j < p.GetCount(); j++)
|
||||
sw.Line(p[j].x, p[j].y);
|
||||
sw.NoAA().Fill(l[i].color);
|
||||
}
|
||||
}
|
||||
|
||||
void Demo(Painter& sw)
|
||||
{
|
||||
PaintLion(sw);
|
||||
|
|
@ -212,5 +224,6 @@ void Demo(Painter& sw)
|
|||
|
||||
INITBLOCK {
|
||||
RegisterExample("Lion", PaintLion);
|
||||
RegisterExample("Lion NoAA", PaintLionNoAA);
|
||||
RegisterExample("U++ Painter", Demo);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue