From 97c1de64ccb8828d260024cc64a76d3924d7962b Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 16 Jan 2005 17:08:21 +0000 Subject: Added drawImageRect function to Graphics class. --- src/graphic/graphic.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ src/graphic/graphic.h | 12 ++++++++++++ 2 files changed, 52 insertions(+) (limited to 'src/graphic') 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 @@ -102,6 +102,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. -- cgit v1.2.3-70-g09d2