aboutsummaryrefslogtreecommitdiff
path: root/engines/wage/design.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2015-12-19 23:30:45 +0100
committerEugene Sandulenko2015-12-27 15:40:57 +0100
commit6c214c2c4a9d1f0047009fd5eddbcd78aaa3542f (patch)
tree59c3f1c07d0371e46a82478a38f9194086ed10f1 /engines/wage/design.cpp
parent3b94913e174b6ba19226a78b6d55872d0b7576aa (diff)
downloadscummvm-rg350-6c214c2c4a9d1f0047009fd5eddbcd78aaa3542f.tar.gz
scummvm-rg350-6c214c2c4a9d1f0047009fd5eddbcd78aaa3542f.tar.bz2
scummvm-rg350-6c214c2c4a9d1f0047009fd5eddbcd78aaa3542f.zip
WAGE: Special case for 1-pixel wide ellipses, support for transparent pattern
Diffstat (limited to 'engines/wage/design.cpp')
-rw-r--r--engines/wage/design.cpp45
1 files changed, 34 insertions, 11 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp
index 05727cd2f0..9bd2fe6c4d 100644
--- a/engines/wage/design.cpp
+++ b/engines/wage/design.cpp
@@ -270,14 +270,23 @@ void Design::drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool m
plotData pd(surface, &patterns, borderFillType);
if (mask) {
- drawFilledEllipse(x1, y1, x2, y2, drawPixelPlain, &pd);
+ drawEllipse(x1, y1, x2, y2, true, drawPixelPlain, &pd);
return;
}
- drawFilledEllipse(x1, y1, x2-1, y2-1, drawPixel, &pd);
+ if (borderThickness > 0) {
+ if (borderThickness == 1) {
+ drawEllipse(x1, y1, x2-1, y2-1, false, drawPixel, &pd);
+ } else {
+ drawEllipse(x1, y1, x2-1, y2-1, true, drawPixel, &pd);
+ warning("Ellips thickness >1: borderThickness");
+ }
+ }
- pd.fillType = fillType;
- drawFilledEllipse(x1+borderThickness, y1+borderThickness, x2-1-2*borderThickness, y2-2*borderThickness, drawPixel, &pd);
+ if (fillType <= patterns.size()) {
+ pd.fillType = fillType;
+ drawEllipse(x1+borderThickness, y1+borderThickness, x2-1-2*borderThickness, y2-2*borderThickness, true, drawPixel, &pd);
+ }
}
void Design::drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask) {
@@ -414,7 +423,7 @@ void Design::drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &
}
// http://members.chello.at/easyfilter/bresenham.html
-void Design::drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(int, int, int, void *), void *data) {
+void Design::drawEllipse(int x0, int y0, int x1, int y1, bool filled, void (*plotProc)(int, int, int, void *), void *data) {
int a = abs(x1-x0), b = abs(y1-y0), b1 = b&1; /* values of diameter */
long dx = 4*(1-a)*b*b, dy = 4*(b1+1)*a*a; /* error increment */
long err = dx+dy+b1*a*a, e2; /* error of 1.step */
@@ -425,19 +434,33 @@ void Design::drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(
a *= 8*a; b1 = 8*b*b;
do {
- drawHLine(x0, x1, y0, kColorBlack, plotProc, data);
- drawHLine(x0, x1, y1, kColorBlack, plotProc, data);
+ if (filled) {
+ drawHLine(x0, x1, y0, kColorBlack, plotProc, data);
+ drawHLine(x0, x1, y1, kColorBlack, plotProc, data);
+ } else {
+ (*plotProc)(x1, y0, kColorBlack, data); /* I. Quadrant */
+ (*plotProc)(x0, y0, kColorBlack, data); /* II. Quadrant */
+ (*plotProc)(x0, y1, kColorBlack, data); /* III. Quadrant */
+ (*plotProc)(x1, y1, kColorBlack, data); /* IV. Quadrant */
+ }
e2 = 2*err;
if (e2 <= dy) { y0++; y1--; err += dy += a; } /* y step */
if (e2 >= dx || 2*err > dy) { x0++; x1--; err += dx += b1; } /* x step */
} while (x0 <= x1);
while (y0-y1 < b) { /* too early stop of flat ellipses a=1 */
- drawHLine(x0-1, x0-1, y0, kColorBlack, plotProc, data); /* -> finish tip of ellipse */
- drawHLine(x1+1, x1+1, y0, kColorBlack, plotProc, data);
+ if (filled) {
+ drawHLine(x0-1, x0-1, y0, kColorBlack, plotProc, data); /* -> finish tip of ellipse */
+ drawHLine(x1+1, x1+1, y0, kColorBlack, plotProc, data);
+ drawHLine(x0-1, x0-1, y1, kColorBlack, plotProc, data);
+ drawHLine(x1+1, x1+1, y1, kColorBlack, plotProc, data);
+ } else {
+ (*plotProc)(x0-1, y0, kColorBlack, data); /* -> finish tip of ellipse */
+ (*plotProc)(x1+1, y0, kColorBlack, data);
+ (*plotProc)(x0-1, y1, kColorBlack, data);
+ (*plotProc)(x1+1, y1, kColorBlack, data);
+ }
y0++;
- drawHLine(x0-1, x0-1, y1, kColorBlack, plotProc, data);
- drawHLine(x1+1, x1+1, y1, kColorBlack, plotProc, data);
y1--;
}
}