diff options
author | Eugene Sandulenko | 2015-12-20 11:55:16 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2015-12-27 15:40:57 +0100 |
commit | c17c2421f42e3cf67dbfcc956502c00652a14fec (patch) | |
tree | b51d8d84f3f94ae9cb518e20ecc94ddec5460879 /engines | |
parent | a616e9fb093bc3c0aeea8f5dbaf088f201c414c3 (diff) | |
download | scummvm-rg350-c17c2421f42e3cf67dbfcc956502c00652a14fec.tar.gz scummvm-rg350-c17c2421f42e3cf67dbfcc956502c00652a14fec.tar.bz2 scummvm-rg350-c17c2421f42e3cf67dbfcc956502c00652a14fec.zip |
WAGE: Improved rounded rects. Now rects with radius > side are drawn correctly
Diffstat (limited to 'engines')
-rw-r--r-- | engines/wage/design.cpp | 75 |
1 files changed, 62 insertions, 13 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp index 0c0d20506a..7d78df8529 100644 --- a/engines/wage/design.cpp +++ b/engines/wage/design.cpp @@ -60,6 +60,9 @@ struct plotData { surface(s), patterns(p), fillType(f) {} }; +void drawPixel(int x, int y, int color, void *data); +void drawPixelPlain(int x, int y, int color, void *data); + Design::Design(Common::SeekableReadStream *data) { _len = data->readUint16BE() - 2; _data = (byte *)malloc(_len); @@ -77,6 +80,24 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) { canvas->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite); } +/* + plotData pd(canvas, &patterns, 8); + Common::Rect inn(50, 50, 80, 150); + drawFilledRect(inn, kColorGray, drawPixelPlain, &pd); + drawFilledRoundRect(inn, 10, kColorBlack, drawPixelPlain, &pd); + Common::Rect inn2(100, 100, 200, 110); + drawFilledRect(inn2, kColorGray, drawPixelPlain, &pd); + drawFilledRoundRect(inn2, 10, kColorBlack, drawPixelPlain, &pd); + g_system->copyRectToScreen(canvas->getPixels(), canvas->pitch, 0, 0, canvas->w, canvas->h); + + while (true) { + ((WageEngine *)g_engine)->processEvents(); + g_system->updateScreen(); + g_system->delayMillis(50); + } + return; +*/ + while (!in.eos()) { byte fillType = in.readByte(); byte borderThickness = in.readByte(); @@ -370,20 +391,48 @@ void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, // http://members.chello.at/easyfilter/bresenham.html void Design::drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data) { - int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */ - int dy = rect.height() - arc * 2; - int r = arc; + if (rect.height() < rect.width()) { + int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */ + int dy = rect.height() - arc * 2; + int r = arc; + int stop = 0; + if (dy < 0) + stop = -dy / 2; + + do { + drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r-stop, color, plotProc, data); + drawHLine(rect.left+x+r, rect.right-x-r, rect.bottom+y-r+stop, color, plotProc, data); + arc = err; + if (arc <= y) err += ++y*2+1; /* e_xy+e_y < 0 */ + if (arc > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */ + if (stop && y > stop) + break; + } while (x < 0); - do { - drawHLine(rect.left+x+r, rect.right-x-r, rect.top-y+r, color, plotProc, data); - drawHLine(rect.left+x+r, rect.right-x-r, rect.top+y+dy+r, color, plotProc, data); - arc = err; - if (arc <= y) err += ++y*2+1; /* e_xy+e_y < 0 */ - if (arc > x || err > y) err += ++x*2+1; /* e_xy+e_x > 0 or no 2nd y-step */ - } while (x < 0); - - for (int i = 0; i < dy; i++) - drawHLine(rect.left, rect.right, rect.top + r + i, color, plotProc, data); + for (int i = 0; i < dy; i++) + drawHLine(rect.left, rect.right, rect.top + r + i, color, plotProc, data); + } else { + int y = -arc, x = 0, err = 2-2*arc; /* II. Quadrant */ + int dx = rect.width() - arc * 2; + int r = arc; + int stop = 0; + if (dx < 0) + stop = -dx / 2; + + do { + drawVLine(rect.left-x+r-stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data); + drawVLine(rect.right+x-r+stop, rect.top+y+r, rect.bottom-y-r, color, plotProc, data); + + arc = err; + if (arc <= x) err += ++x*2+1; /* e_xy+e_y < 0 */ + if (arc > y || err > x) err += ++y*2+1; /* e_xy+e_x > 0 or no 2nd y-step */ + if (stop && x > stop) + break; + } while (y < 0); + + for (int i = 0; i < dx; i++) + drawVLine(rect.left + r + i, rect.top, rect.bottom, color, plotProc, data); + } } // Based on public-domain code by Darel Rex Finley, 2007 |