diff options
author | Sven Hesse | 2012-06-21 23:59:59 +0200 |
---|---|---|
committer | Sven Hesse | 2012-06-22 18:10:52 +0200 |
commit | 62cf66395736e1cc368b31588472fe9d74221c87 (patch) | |
tree | bfa8190c84f3be0ae5958ff77b5b473d6bf268ef /engines/gob | |
parent | b1e50b4e304b267afda1c48a4edb77b21058ed45 (diff) | |
download | scummvm-rg350-62cf66395736e1cc368b31588472fe9d74221c87.tar.gz scummvm-rg350-62cf66395736e1cc368b31588472fe9d74221c87.tar.bz2 scummvm-rg350-62cf66395736e1cc368b31588472fe9d74221c87.zip |
GOB: Add Surface::drawRect()
Diffstat (limited to 'engines/gob')
-rw-r--r-- | engines/gob/surface.cpp | 28 | ||||
-rw-r--r-- | engines/gob/surface.h | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/engines/gob/surface.cpp b/engines/gob/surface.cpp index 3af19f891d..3eaf741be2 100644 --- a/engines/gob/surface.cpp +++ b/engines/gob/surface.cpp @@ -695,6 +695,34 @@ void Surface::drawLine(uint16 x0, uint16 y0, uint16 x1, uint16 y1, uint32 color) Graphics::drawLine(x0, y0, x1, y1, color, &plotPixel, this); } +void Surface::drawRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uint32 color) { + // Just in case those are swapped + if (left > right) + SWAP(left, right); + if (top > bottom) + SWAP(top, bottom); + + if ((left >= _width) || (top >= _height)) + // Nothing to do + return; + + // Area to actually draw + const uint16 width = CLIP<int32>(right - left + 1, 0, _width - left); + const uint16 height = CLIP<int32>(bottom - top + 1, 0, _height - top); + + if ((width == 0) || (height == 0)) + // Nothing to do + return; + + right = left + width - 1; + bottom = top + height - 1; + + drawLine(left , top , left , bottom, color); + drawLine(right, top , right, bottom, color); + drawLine(left , top , right, top , color); + drawLine(left , bottom, right, bottom, color); +} + /* * The original's version of the Bresenham Algorithm was a bit "unclean" * and produced strange edges at 45, 135, 225 and 315 degrees, so using the diff --git a/engines/gob/surface.h b/engines/gob/surface.h index 5376603801..09be8d1a49 100644 --- a/engines/gob/surface.h +++ b/engines/gob/surface.h @@ -158,6 +158,7 @@ public: void putPixel(uint16 x, uint16 y, uint32 color); void drawLine(uint16 x0, uint16 y0, uint16 x1, uint16 y1, uint32 color); + void drawRect(uint16 left, uint16 top, uint16 right, uint16 bottom, uint32 color); void drawCircle(uint16 x0, uint16 y0, uint16 radius, uint32 color, int16 pattern = 0); void blitToScreen(uint16 left, uint16 top, uint16 right, uint16 bottom, uint16 x, uint16 y) const; |