aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/surface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob/surface.cpp')
-rw-r--r--engines/gob/surface.cpp28
1 files changed, 28 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