From 98ab68f00d90e4b7892e774b69792687d2f5fc74 Mon Sep 17 00:00:00 2001 From: Pk11 Date: Thu, 14 Jan 2021 13:52:47 -0600 Subject: [PATCH] Fix max size outlines --- source/graphics.cpp | 12 ++++++------ source/sprite.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/graphics.cpp b/source/graphics.cpp index fda2fb5..e65e532 100644 --- a/source/graphics.cpp +++ b/source/graphics.cpp @@ -70,16 +70,16 @@ void Graphics::clear(bool top, int layer) { toncset(bgGetGfxPtr(top ? layer : la void Graphics::drawOutline(int x, int y, int w, int h, u8 color, bool top, int layer) { u8 *dst = (u8 *)bgGetGfxPtr(top ? layer : layer + 4); h += y; - if(y >= 0 && y < 192) - toncset(dst + y * 256 + std::max(x, 0), color, std::min(w, 256 - x - w)); + if(y >= 0 && y <= 192) + toncset(dst + y * 256 + std::max(x, 0), color, std::min(w, 256 - x)); for(y++; y < (h - 1); y++) { - if(y >= 0 && y < 192 && x > 0) + if(y >= 0 && y <= 192 && x >= 0) toncset(dst + y * 256 + x, color, 1); - if(y >= 0 && y < 192 && x + w < 256) + if(y >= 0 && y <= 192 && x + w <= 256) toncset(dst + y * 256 + x + w - 1, color, 1); } - if(y >= 0 && y < 192) - toncset(dst + y * 256 + std::max(x, 0), color, std::min(w, 256 - x - w)); + if(y >= 0 && y <= 192) + toncset(dst + y * 256 + std::max(x, 0), color, std::min(w, 256 - x)); } void Graphics::drawRectangle(int x, int y, int w, int h, u8 color, bool top, bool layer) { diff --git a/source/sprite.cpp b/source/sprite.cpp index 16da4b6..04d1266 100644 --- a/source/sprite.cpp +++ b/source/sprite.cpp @@ -171,16 +171,16 @@ void Sprite::fillColor(u16 color) { toncset16(_gfx, color, (_size & 0xFF) << 5); void Sprite::drawOutline(int x, int y, int w, int h, u16 color) { h += y; - if(y >= 0 && y < _height) - toncset16(_gfx + y * _width + std::max(x, 0), color, std::min(w, _width - x - w)); + if(y >= 0 && y <= _height) + toncset16(_gfx + y * _width + std::max(x, 0), color, std::min(w, _width - x)); for(y++; y < (h - 1); y++) { - if(y >= 0 && y < _height && x > 0) + if(y >= 0 && y <= _height && x >= 0) _gfx[y * _width + x] = color; - if(y >= 0 && y < _height && x + w < _width) + if(y >= 0 && y <= _height && x + w <= _width) _gfx[y * _width + x + w - 1] = color; } - if(y >= 0 && y < _height) - toncset16(_gfx + y * _width + std::max(x, 0), color, std::min(w, _width - x - w)); + if(y >= 0 && y <= _height) + toncset16(_gfx + y * _width + std::max(x, 0), color, std::min(w, _width - x)); } void Sprite::drawRectangle(int x, int y, int w, int h, u16 color1, u16 color2) {