Skip to content

Commit

Permalink
WAGE: Implement drawing patterned rectangles
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Dec 27, 2015
1 parent 5ebbe35 commit 539c2ea
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
30 changes: 21 additions & 9 deletions engines/wage/design.cpp
Expand Up @@ -64,7 +64,7 @@ Design::~Design() {
void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {
Common::MemoryReadStream in(_data, _len);

if (mask) {
if (mask || 1) {
//canvas.setColor(Color.WHITE);
canvas->fillRect(Common::Rect(0, 0, _bounds->width(), _bounds->height()), kColorWhite);
//canvas.setColor(Color.BLACK);
Expand Down Expand Up @@ -114,19 +114,19 @@ void Design::paint(Graphics::Surface *canvas, Patterns &patterns, bool mask) {

void Design::drawRect(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType) {
int16 y = in.readSint16BE();
int16 x = in.readSint16BE();
int16 height = in.readSint16BE();
int16 width = in.readSint16BE();
Common::Rect outer(x, y, width, height);
int16 y1 = in.readSint16BE();
int16 x1 = in.readSint16BE();
int16 y2 = in.readSint16BE();
int16 x2 = in.readSint16BE();
Common::Rect outer(x1, y1, x2, y2);

if (mask) {
surface->fillRect(outer, kColorBlack);
return;
}
//Shape inner = new Rectangle(x+borderThickness, y+borderThickness, width-2*borderThickness, height-2*borderThickness);
//paintShape(g2d, patterns, outer, inner, borderFillType, fillType);
surface->frameRect(outer, kColorBlack);
fillType = 7;
Common::Rect inner(x1 + borderThickness, y1 + borderThickness, x2 - borderThickness, y2 - borderThickness);
patternThickRect(surface, patterns, outer, inner, borderFillType, fillType);
}

void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Expand Down Expand Up @@ -230,5 +230,17 @@ void Design::drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, boo
free(ypoints);
}

void Design::patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer,
Common::Rect &inner, byte borderFillType, byte fillType) {
patternRect(surface, patterns, outer, borderFillType);
patternRect(surface, patterns, inner, fillType);
}

void Design::patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType) {
for (int y = rect.top; y < rect.bottom; y++)
for (int x = rect.left; x < rect.right; x++)
if (patterns[fillType][(y - rect.top) % 8] & (1 << (7 - (x - rect.left) % 8)))
*((byte *)surface->getBasePtr(x, y)) = kColorBlack;
}

} // End of namespace Wage
5 changes: 5 additions & 0 deletions engines/wage/design.h
Expand Up @@ -86,6 +86,11 @@ class Design {
void drawPolygon(Graphics::Surface *surface, Common::ReadStream &in, bool mask,
Patterns &patterns, byte fillType, byte borderThickness, byte borderFillType);

void patternThickRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &outer,
Common::Rect &inner, byte borderFillType, byte fillType);

void patternRect(Graphics::Surface *surface, Patterns &patterns, Common::Rect &rect, byte fillType);

};

} // End of namespace Wage
Expand Down
2 changes: 1 addition & 1 deletion engines/wage/wage.cpp
Expand Up @@ -109,7 +109,7 @@ Common::Error WageEngine::run() {
screen.create(320, 200, Graphics::PixelFormat::createFormatCLUT8());
Common::Rect r(0, 0, 320, 200);
_world->_scenes["entry"]->_design->setBounds(&r);
_world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, true);
_world->_scenes["entry"]->_design->paint(&screen, _world->_patterns, false);

return Common::kNoError;
}
Expand Down

0 comments on commit 539c2ea

Please sign in to comment.