summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/graphic/graphic.cpp40
-rw-r--r--src/graphic/graphic.h12
2 files changed, 52 insertions, 0 deletions
diff --git a/src/graphic/graphic.cpp b/src/graphic/graphic.cpp
index 71fc5a75..281c3c89 100644
--- a/src/graphic/graphic.cpp
+++ b/src/graphic/graphic.cpp
@@ -160,6 +160,46 @@ Graphics::~Graphics() {
destroy_bitmap(buffer);
}
+void Graphics::drawImageRect(
+ int x, int y, int w, int h,
+ Image *topLeft, Image *topRight,
+ Image *bottomLeft, Image *bottomRight,
+ Image *top, Image *right,
+ Image *bottom, Image *left,
+ Image *center)
+{
+ // Draw the center area
+ center->drawPattern(buffer,
+ x + topLeft->getWidth(), y + topLeft->getHeight(),
+ w - topLeft->getWidth() - topRight->getWidth(),
+ h - topLeft->getHeight() - bottomLeft->getHeight());
+
+ // Draw the sides
+ top->drawPattern(buffer,
+ x + topLeft->getWidth(), y,
+ w - topLeft->getWidth() - topRight->getWidth(), top->getHeight());
+ bottom->drawPattern(buffer,
+ x + bottomLeft->getWidth(), y + h - bottom->getHeight(),
+ w - bottomLeft->getWidth() - bottomRight->getWidth(),
+ bottom->getHeight());
+ left->drawPattern(buffer,
+ x, y + topLeft->getHeight(),
+ left->getWidth(),
+ h - topLeft->getHeight() - bottomLeft->getHeight());
+ right->drawPattern(buffer,
+ x + w - right->getWidth(), y + topRight->getHeight(),
+ right->getWidth(),
+ h - topRight->getHeight() - bottomRight->getHeight());
+
+ // Draw the corners
+ topLeft->draw(buffer, x, y);
+ topRight->draw(buffer, x + w - topRight->getWidth(), y);
+ bottomLeft->draw(buffer, x, y + h - bottomLeft->getHeight());
+ bottomRight->draw(buffer,
+ x + w - bottomRight->getWidth(),
+ y + h - bottomRight->getHeight());
+}
+
void Graphics::updateScreen()
{
blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
diff --git a/src/graphic/graphic.h b/src/graphic/graphic.h
index a3701531..5b61bb28 100644
--- a/src/graphic/graphic.h
+++ b/src/graphic/graphic.h
@@ -103,6 +103,18 @@ class Graphics : public gcn::AllegroGraphics {
~Graphics();
/**
+ * Draws a rectangle using 4 corner images, 4 side images and 1 image
+ * for the inside.
+ */
+ void drawImageRect(
+ int x, int y, int w, int h,
+ Image *topLeft, Image *topRight,
+ Image *bottomLeft, Image *bottomRight,
+ Image *top, Image *right,
+ Image *bottom, Image *left,
+ Image *center);
+
+ /**
* Updates the screen. This is done by either copying the buffer to the
* screen or swapping pages.
*/