diff options
author | Eugene Sandulenko | 2015-12-19 12:33:05 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2015-12-27 15:40:55 +0100 |
commit | 0d6b726fd82d1ecb36d784625c60a839b674f729 (patch) | |
tree | debe2203e53823bad0ff8ff290708b1c7ce1f82d /engines/wage | |
parent | 7e23caa342389658db122ac668a7a5b9cf63d6ab (diff) | |
download | scummvm-rg350-0d6b726fd82d1ecb36d784625c60a839b674f729.tar.gz scummvm-rg350-0d6b726fd82d1ecb36d784625c60a839b674f729.tar.bz2 scummvm-rg350-0d6b726fd82d1ecb36d784625c60a839b674f729.zip |
WAGE: First stub for rounded rectangles
Diffstat (limited to 'engines/wage')
-rw-r--r-- | engines/wage/design.cpp | 67 | ||||
-rw-r--r-- | engines/wage/design.h | 3 | ||||
-rw-r--r-- | engines/wage/wage.cpp | 8 |
3 files changed, 71 insertions, 7 deletions
diff --git a/engines/wage/design.cpp b/engines/wage/design.cpp index e3cc73f124..ec98eb65c5 100644 --- a/engines/wage/design.cpp +++ b/engines/wage/design.cpp @@ -89,11 +89,9 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) { case 4: drawRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType); break; - /* case 8: drawRoundRect(canvas, in, mask, patterns, fillType, borderThickness, borderFillType); break; - */ case 12: drawOval(canvas, in, mask, patterns, fillType, borderThickness, borderFillType); break; @@ -123,13 +121,15 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) { void drawPixel(int x, int y, int color, void *data) { plotData *p = (plotData *)data; - if (p->fillType > (*p->patterns).size()) + if (p->fillType > p->patterns->size()) return; - if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) + if (x >= 0 && x < p->surface->w && y >= 0 && y < p->surface->h) { + byte *pat = p->patterns->operator[](p->fillType - 1); *((byte *)p->surface->getBasePtr(x, y)) = - ((*p->patterns)[p->fillType - 1][(y - p->y0) % 8] & (1 << (7 - (x - p->x0) % 8))) ? + (pat[(y - p->y0) % 8] & (1 << (7 - (x - p->x0) % 8))) ? color : kColorWhite; + } } void drawPixelPlain(int x, int y, int color, void *data) { @@ -162,6 +162,36 @@ void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool m drawFilledRect(inner, kColorBlack, drawPixel, &pd); } +void Design::drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask, + Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) { + int16 y1 = in.readSint16BE(); + int16 x1 = in.readSint16BE(); + int16 y2 = in.readSint16BE(); + int16 x2 = in.readSint16BE(); + int16 arc = in.readSint16BE(); + Common::Rect outer(x1, y1, x2, y2); + + plotData pd(surface, &patterns, borderFillType, x1, y1); + + if (mask) { + drawFilledRoundRect(outer, arc, kColorBlack, drawPixelPlain, &pd); + return; + } + Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness); + + //drawFilledRoundRect(outer, arc, kColorBlack, drawPixel, &pd); + + pd.fillType = fillType; + + //drawFilledRoundRect(inner, arc, kColorBlack, drawPixel, &pd); + + + Common::Rect inn(50, 50, 400, 400); + pd.fillType = 8; + drawFilledRect(inn, kColorBlack, drawPixel, &pd); + //drawFilledRoundRect(inn, arc, kColorBlack, drawPixel, &pd); +} + void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) { @@ -323,6 +353,33 @@ void Design::drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, drawHLine(rect.left, rect.right, y, color, plotProc, data); } +// 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) { + //drawFilledRect(rect, color, plotProc, data); + //return; + int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */ + int dx = rect.width() - arc * 2; + int dy = rect.height() - arc * 2; + + do { + //drawHLine(rect.left, rect.right, y, color, plotProc, data); + + //drawPixelPlain(rect.left-x, rect.top-y, color, data); /* I. Quadrant */ + //drawPixelPlain(rect.left+x, rect.top-y, color, data); /* II. Quadrant */ + drawHLine(rect.left+x, rect.right-x, rect.top-y, color, drawPixelPlain, data); + drawHLine(rect.left+x, rect.right-x, rect.top+y+dy, color, drawPixelPlain, data); + //drawPixelPlain(rect.left-y, rect.top-x, color, data); /* II. Quadrant */ + //drawPixelPlain(rect.left+x, rect.top-y, color, data); /* III. Quadrant */ + //drawPixelPlain(rect.left+y, rect.top+x, color, data); /* IV. Quadrant */ + 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 + arc + i, color, drawPixelPlain, data); +} // Based on public-domain code by Darel Rex Finley, 2007 // http://alienryderflex.com/polygon_fill/ diff --git a/engines/wage/design.h b/engines/wage/design.h index da0a6bc4ab..365f6c1616 100644 --- a/engines/wage/design.h +++ b/engines/wage/design.h @@ -83,6 +83,8 @@ private: private: void drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType); + void drawRoundRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask, + Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType); void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask, Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType); void drawOval(Graphics::Surface *surface, Common::ReadStream &in, bool mask, @@ -90,6 +92,7 @@ private: void drawBitmap(Graphics::Surface *surface, Common::ReadStream &in, bool mask); void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data); + void drawFilledRoundRect(Common::Rect &rect, int arc, int color, void (*plotProc)(int, int, int, void *), void *data); void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color, void (*plotProc)(int, int, int, void *), void *data); void drawFilledEllipse(int x0, int y0, int x1, int y1, void (*plotProc)(int, int, int, void *), void *data); diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp index f6477ddf0b..0503168449 100644 --- a/engines/wage/wage.cpp +++ b/engines/wage/wage.cpp @@ -108,8 +108,12 @@ Common::Error WageEngine::run() { Graphics::Surface screen; screen.create(640, 480, Graphics::PixelFormat::createFormatCLUT8()); Common::Rect r(0, 0, screen.w, screen.h); - _world->_scenes["entry"]->_design->setBounds(&r); - _world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, false); + //_world->_objs["frank.1"]->_design->setBounds(&r); + //_world->_objs["frank.1"]->_design->paint(&screen, _world->_patterns, false); + //_world->_scenes["temple of the holy mackeral"]->_design->setBounds(&r); + //_world->_scenes["temple of the holy mackeral"]->_design->paint(&screen, _world->_patterns, false); + _world->_scenes["tower level 3"]->_design->setBounds(&r); + _world->_scenes["tower level 3"]->_design->paint(&screen, _world->_patterns, false); return Common::kNoError; } |