diff --git a/src/PowderToyRenderer.cpp b/src/PowderToyRenderer.cpp index 6f8b063b54..b1159b25fe 100644 --- a/src/PowderToyRenderer.cpp +++ b/src/PowderToyRenderer.cpp @@ -62,8 +62,8 @@ int main(int argc, char *argv[]) else { int w = Graphics::TextSize("Save file invalid").X + 15, x = (XRES-w)/2, y = (YRES-24)/2; - ren->drawrect(x, y, w, 24, 192, 192, 192, 255); - ren->BlendText({ x+8, y+8 }, "Save file invalid", RGBA(192, 192, 240, 255)); + ren->DrawRect(RectSized(Vec2{ x, y }, Vec2{ w, 24 }), 0xC0C0C0_rgb); + ren->BlendText({ x+8, y+8 }, "Save file invalid", 0xC0C0F0_rgb .WithAlpha(255)); } ren->RenderBegin(); diff --git a/src/debug/DebugLines.cpp b/src/debug/DebugLines.cpp index c5b921de26..74d1195952 100644 --- a/src/debug/DebugLines.cpp +++ b/src/debug/DebugLines.cpp @@ -21,26 +21,25 @@ void DebugLines::Draw() ui::Point drawPoint1 = controller->PointTranslate(view->GetLineStartCoords()), drawPoint2 = controller->PointTranslate(view->GetLineFinishCoords()); if (view->GetDrawSnap()) drawPoint2 = view->lineSnapCoords(drawPoint1, drawPoint2); - //g->draw_line(drawPoint1.X, drawPoint1.Y, drawPoint2.X, drawPoint2.Y, 255, 0, 255, 255); - g->draw_line(0, drawPoint1.Y, XRES, drawPoint1.Y, 255, 255, 255, 120); - g->draw_line(drawPoint1.X, 0, drawPoint1.X, YRES, 255, 255, 255, 120); + g->BlendLine({ 0, drawPoint1.Y }, { XRES, drawPoint1.Y }, 0xFFFFFF_rgb .WithAlpha(120)); + g->BlendLine({ drawPoint1.X, 0 }, { drawPoint1.X, YRES }, 0xFFFFFF_rgb .WithAlpha(120)); - g->draw_line(0, drawPoint2.Y, XRES, drawPoint2.Y, 255, 255, 255, 120); - g->draw_line(drawPoint2.X, 0, drawPoint2.X, YRES, 255, 255, 255, 120); + g->BlendLine({ 0, drawPoint2.Y }, { XRES, drawPoint2.Y }, 0xFFFFFF_rgb .WithAlpha(120)); + g->BlendLine({ drawPoint2.X, 0 }, { drawPoint2.X, YRES }, 0xFFFFFF_rgb .WithAlpha(120)); String info; info = String::Build(drawPoint2.X, " x ", drawPoint2.Y); - g->BlendTextOutline({ drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-(g->TextSize(info).X-1)-3), drawPoint2.Y+(drawPoint2.Y(255, 255, 255, 200)); + g->BlendTextOutline({ drawPoint2.X+(drawPoint2.X>drawPoint1.X?3:-(g->TextSize(info).X-1)-3), drawPoint2.Y+(drawPoint2.YBlendTextOutline({ drawPoint1.X+(drawPoint2.XTextSize(info).X-1)-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3) }, info, RGBA(255, 255, 255, 200)); + g->BlendTextOutline({ drawPoint1.X+(drawPoint2.XTextSize(info).X-1)-2), drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3) }, info, 0xFFFFFF_rgb .WithAlpha(200)); info = String::Build(std::abs(drawPoint2.X-drawPoint1.X)); - g->BlendTextOutline({ (drawPoint1.X+drawPoint2.X)/2-(g->TextSize(info).X-1)/2, drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3) }, info, RGBA(255, 255, 255, 200)); + g->BlendTextOutline({ (drawPoint1.X+drawPoint2.X)/2-(g->TextSize(info).X-1)/2, drawPoint1.Y+(drawPoint2.Y>drawPoint1.Y?-10:3) }, info, 0xFFFFFF_rgb .WithAlpha(200)); info = String::Build(std::abs(drawPoint2.Y-drawPoint1.Y)); - g->BlendTextOutline({ drawPoint1.X+(drawPoint2.XTextSize(info).X-1)-2), (drawPoint1.Y+drawPoint2.Y)/2-3 }, info, RGBA(255, 255, 255, 200)); + g->BlendTextOutline({ drawPoint1.X+(drawPoint2.XTextSize(info).X-1)-2), (drawPoint1.Y+drawPoint2.Y)/2-3 }, info, 0xFFFFFF_rgb .WithAlpha(200)); } } diff --git a/src/debug/DebugParts.cpp b/src/debug/DebugParts.cpp index 6a6cba580f..30748cd5b9 100644 --- a/src/debug/DebugParts.cpp +++ b/src/debug/DebugParts.cpp @@ -22,9 +22,9 @@ void DebugParts::Draw() for (int i = 0; i < NPART; i++) { if (sim->parts[i].type) - g->AddPixel({ x, y }, RGBA(255, 255, 255, 180)); + g->AddPixel({ x, y }, 0xFFFFFF_rgb .WithAlpha(180)); else - g->AddPixel({ x, y }, RGBA(0, 0, 0, 180)); + g->AddPixel({ x, y }, 0x000000_rgb .WithAlpha(180)); if (i == sim->parts_lastActiveIndex) { @@ -38,17 +38,17 @@ void DebugParts::Draw() x = 0; } } - g->draw_line(0, lpy, XRES, lpy, 0, 255, 120, 255); - g->draw_line(lpx, 0, lpx, YRES, 0, 255, 120, 255); - g->AddPixel({ lpx, lpy }, RGBA(255, 50, 50, 220)); + g->DrawLine({ 0, lpy }, { XRES, lpy }, 0x00FF78_rgb); + g->DrawLine({ lpx, 0 }, { lpx, YRES }, 0x00FF78_rgb); + g->AddPixel({ lpx, lpy }, 0xFF3232_rgb .WithAlpha(220)); - g->AddPixel({ lpx+1, lpy }, RGBA(255, 50, 50, 120)); - g->AddPixel({ lpx-1, lpy }, RGBA(255, 50, 50, 120)); - g->AddPixel({ lpx, lpy+1 }, RGBA(255, 50, 50, 120)); - g->AddPixel({ lpx, lpy-1 }, RGBA(255, 50, 50, 120)); + g->AddPixel({ lpx+1, lpy }, 0xFF3232_rgb .WithAlpha(120)); + g->AddPixel({ lpx-1, lpy }, 0xFF3232_rgb .WithAlpha(120)); + g->AddPixel({ lpx, lpy+1 }, 0xFF3232_rgb .WithAlpha(120)); + g->AddPixel({ lpx, lpy-1 }, 0xFF3232_rgb .WithAlpha(120)); - g->fillrect(7, YRES-26, g->TextSize(info).X + 4, 14, 0, 0, 0, 180); - g->BlendText({ 10, YRES-22 }, info, RGBA(255, 255, 255, 255)); + g->BlendFilledRect(RectSized(Vec2{ 7, YRES-26}, Vec2{ g->TextSize(info).X + 4, 14}), 0x000000_rgb .WithAlpha(180)); + g->BlendText({ 10, YRES-22 }, info, 0xFFFFFF_rgb .WithAlpha(255)); } DebugParts::~DebugParts() diff --git a/src/debug/ElementPopulation.cpp b/src/debug/ElementPopulation.cpp index b93ba9b196..76ec04133f 100644 --- a/src/debug/ElementPopulation.cpp +++ b/src/debug/ElementPopulation.cpp @@ -44,7 +44,7 @@ void ElementPopulationDebug::Draw() halfValString = String::Build(maxAverage/2); - g->fillrect(xStart-5, yBottom - 263, bars+10+Graphics::TextSize(maxValString).X+9, 255 + 13, 0, 0, 0, 180); + g->BlendFilledRect(RectSized(Vec2{ xStart-5, yBottom - 263 }, Vec2{ bars+10+Graphics::TextSize(maxValString).X+9, 255 + 13 }), 0x000000_rgb .WithAlpha(180)); bars = 0; for(int i = 0; i < PT_NUM; i++) @@ -57,28 +57,28 @@ void ElementPopulationDebug::Draw() RGB colour = sim->elements[i].Colour; - g->draw_line(xStart+barX, yBottom+3, xStart+barX, yBottom+2, colour.Red, colour.Green, colour.Blue, 255); + g->DrawLine({ xStart+barX, yBottom+3 }, { xStart+barX, yBottom+2 }, colour); if(sim->elementCount[i]) { if(barSize > 256) { barSize = 256; - g->blendpixel(xStart+barX, yBottom-barSize-3, colour.Red, colour.Green, colour.Blue, 255); - g->blendpixel(xStart+barX, yBottom-barSize-5, colour.Red, colour.Green, colour.Blue, 255); - g->blendpixel(xStart+barX, yBottom-barSize-7, colour.Red, colour.Green, colour.Blue, 255); + g->DrawPixel({ xStart+barX, yBottom-barSize-3 }, colour); + g->DrawPixel({ xStart+barX, yBottom-barSize-5 }, colour); + g->DrawPixel({ xStart+barX, yBottom-barSize-7 }, colour); } else { - g->draw_line(xStart+barX, yBottom-barSize-3, xStart+barX, yBottom-barSize-2, 255, 255, 255, 180); + g->BlendLine({ xStart+barX, yBottom-barSize-3 }, { xStart+barX, yBottom-barSize-2 }, 0xFFFFFF_rgb .WithAlpha(180)); } - g->draw_line(xStart+barX, yBottom-barSize, xStart+barX, yBottom, colour.Red, colour.Green, colour.Blue, 255); + g->DrawLine({ xStart+barX, yBottom-barSize }, { xStart+barX, yBottom }, colour); } bars++; } } - g->BlendText({ xStart + bars + 5, yBottom-5 }, "0", RGBA(255, 255, 255, 255)); - g->BlendText({ xStart + bars + 5, yBottom-132 }, halfValString, RGBA(255, 255, 255, 255)); - g->BlendText({ xStart + bars + 5, yBottom-260 }, maxValString, RGBA(255, 255, 255, 255)); + g->BlendText({ xStart + bars + 5, yBottom-5 }, "0", 0xFFFFFF_rgb .WithAlpha(255)); + g->BlendText({ xStart + bars + 5, yBottom-132 }, halfValString, 0xFFFFFF_rgb .WithAlpha(255)); + g->BlendText({ xStart + bars + 5, yBottom-260 }, maxValString, 0xFFFFFF_rgb .WithAlpha(255)); } ElementPopulationDebug::~ElementPopulationDebug() diff --git a/src/graphics/Graphics.cpp b/src/graphics/Graphics.cpp index dea739520a..1aa7e805eb 100644 --- a/src/graphics/Graphics.cpp +++ b/src/graphics/Graphics.cpp @@ -174,269 +174,269 @@ void Graphics::draw_icon(int x, int y, Icon icon, unsigned char alpha, bool inve { case IconOpen: if(invert) - BlendChar({ x, y }, 0xE001, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 0xE001, 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 0xE001, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE001, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconReload: if(invert) - BlendChar({ x, y }, 0xE011, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 0xE011, 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 0xE011, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE011, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconSave: if(invert) - BlendChar({ x, y }, 0xE002, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 0xE002, 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 0xE002, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE002, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconVoteUp: if(invert) { - BlendChar({ x-11, y+1 }, 0xE04B, RGBA(0, 100, 0, alpha)); - BlendText({ x+2, y+1 }, ByteString(" 赞").FromUtf8(), RGBA(0, 100, 0, alpha)); + BlendChar({ x-11, y+1 }, 0xE04B, 0x006400_rgb .WithAlpha(alpha)); + BlendText({ x+2, y+1 }, ByteString(" 赞").FromUtf8(), 0x006400_rgb .WithAlpha(alpha)); } else { - BlendChar({ x-11, y+1 }, 0xE04B, RGBA(0, 187, 18, alpha)); - BlendText({ x+2, y+1 }, ByteString(" 赞").FromUtf8(), RGBA(0, 187, 18, alpha)); + BlendChar({ x-11, y+1 }, 0xE04B, 0x00BB12_rgb .WithAlpha(alpha)); + BlendText({ x+2, y+1 }, ByteString(" 赞").FromUtf8(), 0x00BB12_rgb .WithAlpha(alpha)); } break; case IconVoteDown: if(invert) - BlendChar({ x, y }, 0xE04A, RGBA(100, 10, 0, alpha)); + BlendChar({ x, y }, 0xE04A, 0x640A00_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 0xE04A, RGBA(187, 40, 0, alpha)); + BlendChar({ x, y }, 0xE04A, 0xBB2800_rgb .WithAlpha(alpha)); break; case IconTag: if(invert) - BlendChar({ x, y }, 0xE003, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 0xE003, 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 0xE003, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE003, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconNew: if(invert) - BlendChar({ x, y }, 0xE012, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 0xE012, 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 0xE012, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE012, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconLogin: if(invert) - BlendChar({ x, y + 1 }, 0xE004, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y + 1 }, 0xE004, 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x, y + 1 }, 0xE004, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y + 1 }, 0xE004, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconSimulationSettings: if(invert) - BlendChar({ x, y + 1 }, 0xE04F, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y + 1 }, 0xE04F, 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x, y + 1 }, 0xE04F, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y + 1 }, 0xE04F, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconRenderSettings: if(invert) { - BlendChar({ x, y + 1 }, 0xE058, RGBA(255, 0, 0, alpha)); - BlendChar({ x, y + 1 }, 0xE059, RGBA(0, 255, 0, alpha)); - BlendChar({ x, y + 1 }, 0xE05A, RGBA(0, 0, 255, alpha)); + BlendChar({ x, y + 1 }, 0xE058, 0xFF0000_rgb .WithAlpha(alpha)); + BlendChar({ x, y + 1 }, 0xE059, 0x00FF00_rgb .WithAlpha(alpha)); + BlendChar({ x, y + 1 }, 0xE05A, 0x0000FF_rgb .WithAlpha(alpha)); } else { - AddChar({ x, y + 1 }, 0xE058, RGBA(255, 0, 0, alpha)); - AddChar({ x, y + 1 }, 0xE059, RGBA(0, 255, 0, alpha)); - AddChar({ x, y + 1 }, 0xE05A, RGBA(0, 0, 255, alpha)); + AddChar({ x, y + 1 }, 0xE058, 0xFF0000_rgb .WithAlpha(alpha)); + AddChar({ x, y + 1 }, 0xE059, 0x00FF00_rgb .WithAlpha(alpha)); + AddChar({ x, y + 1 }, 0xE05A, 0x0000FF_rgb .WithAlpha(alpha)); } break; case IconPause: if(invert) - BlendChar({ x, y }, 0xE010, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 0xE010, 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 0xE010, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE010, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconFavourite: if(invert) - BlendChar({ x, y }, 0xE04C, RGBA(100, 80, 32, alpha)); + BlendChar({ x, y }, 0xE04C, 0x645020_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 0xE04C, RGBA(192, 160, 64, alpha)); + BlendChar({ x, y }, 0xE04C, 0xC0A040_rgb .WithAlpha(alpha)); break; case IconReport: if(invert) - BlendChar({ x, y }, 0xE063, RGBA(140, 140, 0, alpha)); + BlendChar({ x, y }, 0xE063, 0x8C8C00_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 0xE063, RGBA(255, 255, 0, alpha)); + BlendChar({ x, y }, 0xE063, 0xFFFF00_rgb .WithAlpha(alpha)); break; case IconUsername: if(invert) { - BlendChar({ x, y }, 0xE00B, RGBA(32, 64, 128, alpha)); - BlendChar({ x, y }, 0xE00A, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 0xE00B, 0x204080_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE00A, 0x000000_rgb .WithAlpha(alpha)); } else { - BlendChar({ x, y }, 0xE00B, RGBA(32, 64, 128, alpha)); - BlendChar({ x, y }, 0xE00A, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE00B, 0x204080_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE00A, 0xFFFFFF_rgb .WithAlpha(alpha)); } break; case IconPassword: if(invert) { - BlendChar({ x, y }, 0xE00C, RGBA(160, 144, 32, alpha)); - BlendChar({ x, y }, 0xE004, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 0xE00C, 0xA09020_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE004, 0x000000_rgb .WithAlpha(alpha)); } else { - BlendChar({ x, y }, 0xE00C, RGBA(160, 144, 32, alpha)); - BlendChar({ x, y }, 0xE004, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE00C, 0xA09020_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE004, 0xFFFFFF_rgb .WithAlpha(alpha)); } break; case IconClose: if(invert) - BlendChar({ x, y }, 0xE02A, RGBA(20, 20, 20, alpha)); + BlendChar({ x, y }, 0xE02A, 0x141414_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 0xE02A, RGBA(230, 230, 230, alpha)); + BlendChar({ x, y }, 0xE02A, 0xE6E6E6_rgb .WithAlpha(alpha)); break; case IconVoteSort: if (invert) { - BlendChar({ x, y }, 0xE029, RGBA(44, 48, 32, alpha)); - BlendChar({ x, y }, 0xE028, RGBA(32, 44, 32, alpha)); - BlendChar({ x, y }, 0xE027, RGBA(128, 128, 128, alpha)); + BlendChar({ x, y }, 0xE029, 0x2C3020_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE028, 0x202C20_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE027, 0x808080_rgb .WithAlpha(alpha)); } else { - BlendChar({ x, y }, 0xE029, RGBA(144, 48, 32, alpha)); - BlendChar({ x, y }, 0xE028, RGBA(32, 144, 32, alpha)); - BlendChar({ x, y }, 0xE027, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE029, 0x903020_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE028, 0x209020_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE027, 0xFFFFFF_rgb .WithAlpha(alpha)); } break; case IconDateSort: if (invert) { - BlendChar({ x, y }, 0xE026, RGBA(32, 32, 32, alpha)); + BlendChar({ x, y }, 0xE026, 0x202020_rgb .WithAlpha(alpha)); } else { - BlendChar({ x, y }, 0xE026, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE026, 0xFFFFFF_rgb .WithAlpha(alpha)); } break; case IconMyOwn: if (invert) { - BlendChar({ x, y }, 0xE014, RGBA(192, 160, 64, alpha)); - BlendChar({ x, y }, 0xE013, RGBA(32, 32, 32, alpha)); + BlendChar({ x, y }, 0xE014, 0xC0A040_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE013, 0x202020_rgb .WithAlpha(alpha)); } else { - BlendChar({ x, y }, 0xE014, RGBA(192, 160, 64, alpha)); - BlendChar({ x, y }, 0xE013, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE014, 0xC0A040_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE013, 0xFFFFFF_rgb .WithAlpha(alpha)); } break; case IconSearch: - BlendChar({ x, y }, 0xE00E, RGBA(30, 30, 180, alpha)); - BlendChar({ x, y }, 0xE00F, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE00E, 0x1E1EB4_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE00F, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconDelete: if(invert) { - BlendChar({ x, y }, 0xE006, RGBA(159, 47, 31, alpha)); - BlendChar({ x, y }, 0xE005, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 0xE006, 0x9F2F1F_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE005, 0x000000_rgb .WithAlpha(alpha)); } else { - BlendChar({ x, y }, 0xE006, RGBA(159, 47, 31, alpha)); - BlendChar({ x, y }, 0xE005, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE006, 0x9F2F1F_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE005, 0xFFFFFF_rgb .WithAlpha(alpha)); } break; case IconAdd: if(invert) { - BlendChar({ x, y }, 0xE006, RGBA(32, 144, 32, alpha)); - BlendChar({ x, y }, 0xE009, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 0xE006, 0x209020_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE009, 0x000000_rgb .WithAlpha(alpha)); } else { - BlendChar({ x, y }, 0xE006, RGBA(32, 144, 32, alpha)); - BlendChar({ x, y }, 0xE009, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 0xE006, 0x209020_rgb .WithAlpha(alpha)); + BlendChar({ x, y }, 0xE009, 0xFFFFFF_rgb .WithAlpha(alpha)); } break; case IconVelocity: - BlendChar({ x + 1, y }, 0xE018, RGBA(128, 160, 255, alpha)); + BlendChar({ x + 1, y }, 0xE018, 0x80A0FF_rgb .WithAlpha(alpha)); break; case IconPressure: if(invert) - BlendChar({ x + 1, y + 1 }, 0xE019, RGBA(180, 160, 16, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE019, 0xB4A010_rgb .WithAlpha(alpha)); else - BlendChar({ x + 1, y + 1 }, 0xE019, RGBA(255, 212, 32, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE019, 0xFFD420_rgb .WithAlpha(alpha)); break; case IconPersistant: if(invert) - BlendChar({ x + 1, y + 1 }, 0xE01A, RGBA(20, 20, 20, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE01A, 0x141414_rgb .WithAlpha(alpha)); else - BlendChar({ x + 1, y + 1 }, 0xE01A, RGBA(212, 212, 212, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE01A, 0xD4D4D4_rgb .WithAlpha(alpha)); break; case IconFire: - BlendChar({ x + 1, y + 1 }, 0xE01B, RGBA(255, 0, 0, alpha)); - BlendChar({ x + 1, y + 1 }, 0xE01C, RGBA(255, 255, 64, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE01B, 0xFF0000_rgb .WithAlpha(alpha)); + BlendChar({ x + 1, y + 1 }, 0xE01C, 0xFFFF40_rgb .WithAlpha(alpha)); break; case IconBlob: if(invert) - BlendChar({ x + 1, y }, 0xE03F, RGBA(55, 180, 55, alpha)); + BlendChar({ x + 1, y }, 0xE03F, 0x37B437_rgb .WithAlpha(alpha)); else - BlendChar({ x + 1, y }, 0xE03F, RGBA(55, 255, 55, alpha)); + BlendChar({ x + 1, y }, 0xE03F, 0x37FF37_rgb .WithAlpha(alpha)); break; case IconHeat: - BlendChar({ x + 3, y }, 0xE03E, RGBA(255, 0, 0, alpha)); + BlendChar({ x + 3, y }, 0xE03E, 0xFF0000_rgb .WithAlpha(alpha)); if(invert) - BlendChar({ x + 3, y }, 0xE03D, RGBA(0, 0, 0, alpha)); + BlendChar({ x + 3, y }, 0xE03D, 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x + 3, y }, 0xE03D, RGBA(255, 255, 255, alpha)); + BlendChar({ x + 3, y }, 0xE03D, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconBlur: if(invert) - BlendChar({ x + 1, y }, 0xE044, RGBA(50, 70, 180, alpha)); + BlendChar({ x + 1, y }, 0xE044, 0x3246B4_rgb .WithAlpha(alpha)); else - BlendChar({ x + 1, y }, 0xE044, RGBA(100, 150, 255, alpha)); + BlendChar({ x + 1, y }, 0xE044, 0x6496FF_rgb .WithAlpha(alpha)); break; case IconGradient: if(invert) - BlendChar({ x + 1, y + 1 }, 0xE053, RGBA(255, 50, 255, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE053, 0xFF32FF_rgb .WithAlpha(alpha)); else - BlendChar({ x + 1, y + 1 }, 0xE053, RGBA(205, 50, 205, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE053, 0xCD32CD_rgb .WithAlpha(alpha)); break; case IconLife: if(invert) - BlendChar({ x, y + 1 }, 0xE060, RGBA(0, 0, 0, alpha)); + BlendChar({ x, y + 1 }, 0xE060, 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x, y + 1 }, 0xE060, RGBA(255, 255, 255, alpha)); + BlendChar({ x, y + 1 }, 0xE060, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconEffect: - BlendChar({ x + 1, y }, 0xE061, RGBA(255, 255, 160, alpha)); + BlendChar({ x + 1, y }, 0xE061, 0xFFFFA0_rgb .WithAlpha(alpha)); break; case IconGlow: - BlendChar({ x + 1, y }, 0xE05F, RGBA(200, 255, 255, alpha)); + BlendChar({ x + 1, y }, 0xE05F, 0xC8FFFF_rgb .WithAlpha(alpha)); break; case IconWarp: - BlendChar({ x + 1, y }, 0xE05E, RGBA(255, 255, 255, alpha)); + BlendChar({ x + 1, y }, 0xE05E, 0xFFFFFF_rgb .WithAlpha(alpha)); break; case IconBasic: if(invert) - BlendChar({ x + 1, y + 1 }, 0xE05B, RGBA(50, 50, 0, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE05B, 0x323200_rgb .WithAlpha(alpha)); else - BlendChar({ x + 1, y + 1 }, 0xE05B, RGBA(255, 255, 200, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE05B, 0xFFFFC8_rgb .WithAlpha(alpha)); break; case IconAltAir: if(invert) { - BlendChar({ x + 1, y + 1 }, 0xE054, RGBA(180, 55, 55, alpha)); - BlendChar({ x + 1, y + 1 }, 0xE055, RGBA(55, 180, 55, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE054, 0xB43737_rgb .WithAlpha(alpha)); + BlendChar({ x + 1, y + 1 }, 0xE055, 0x37B437_rgb .WithAlpha(alpha)); } else { - BlendChar({ x + 1, y + 1 }, 0xE054, RGBA(255, 55, 55, alpha)); - BlendChar({ x + 1, y + 1 }, 0xE055, RGBA(55, 255, 55, alpha)); + BlendChar({ x + 1, y + 1 }, 0xE054, 0xFF3737_rgb .WithAlpha(alpha)); + BlendChar({ x + 1, y + 1 }, 0xE055, 0x37FF37_rgb .WithAlpha(alpha)); } break; default: if(invert) - BlendChar({ x, y }, 't', RGBA(0, 0, 0, alpha)); + BlendChar({ x, y }, 't', 0x000000_rgb .WithAlpha(alpha)); else - BlendChar({ x, y }, 't', RGBA(255, 255, 255, alpha)); + BlendChar({ x, y }, 't', 0xFFFFFF_rgb .WithAlpha(alpha)); break; } } diff --git a/src/graphics/RasterDrawMethods.h b/src/graphics/RasterDrawMethods.h index 9fd8051baa..2172f8084d 100644 --- a/src/graphics/RasterDrawMethods.h +++ b/src/graphics/RasterDrawMethods.h @@ -59,13 +59,4 @@ struct RasterDrawMethods static String::const_iterator TextFit(String const &, int width); void Clear(); - - [[deprecated("Use DrawPixel/BlendPixel")]] - void blendpixel(int x, int y, int r, int g, int b, int a); - [[deprecated("Use DrawLine/BlendLine")]] - void draw_line(int x1, int y1, int x2, int y2, int r, int g, int b, int a); - [[deprecated("Use DrawRect/BlendRect")]] - void drawrect(int x, int y, int w, int h, int r, int g, int b, int a); - [[deprecated("Use DrawFilledRect/BlendFilledRect")]] - void fillrect(int x, int y, int w, int h, int r, int g, int b, int a); }; diff --git a/src/graphics/RasterDrawMethodsImpl.h b/src/graphics/RasterDrawMethodsImpl.h index c3685f9d45..37feb7bb53 100644 --- a/src/graphics/RasterDrawMethodsImpl.h +++ b/src/graphics/RasterDrawMethodsImpl.h @@ -400,40 +400,4 @@ String::const_iterator RasterDrawMethods::TextFit(String const &str, in return str.end(); } -template -void RasterDrawMethods::blendpixel(int x, int y, int r, int g, int b, int a) -{ - if (a == 0xFF) - DrawPixel(Vec2(x, y), RGB(r, g, b)); - else - BlendPixel(Vec2(x, y), RGBA(r, g, b, a)); -} - -template -void RasterDrawMethods::draw_line(int x1, int y1, int x2, int y2, int r, int g, int b, int a) -{ - if (a == 0xFF) - DrawLine(Vec2(x1, y1), Vec2(x2, y2), RGB(r, g, b)); - else - BlendLine(Vec2(x1, y1), Vec2(x2, y2), RGBA(r, g, b, a)); -} - -template -void RasterDrawMethods::drawrect(int x, int y, int w, int h, int r, int g, int b, int a) -{ - if (a == 0xFF) - DrawRect(RectSized(Vec2(x, y), Vec2(w, h)), RGB(r, g, b)); - else - BlendRect(RectSized(Vec2(x, y), Vec2(w, h)), RGBA(r, g, b, a)); -} - -template -void RasterDrawMethods::fillrect(int x, int y, int w, int h, int r, int g, int b, int a) -{ - if (a == 0xFF) - DrawFilledRect(RectSized(Vec2(x, y), Vec2(w, h)), RGB(r, g, b)); - else - BlendFilledRect(RectSized(Vec2(x, y), Vec2(w, h)), RGBA(r, g, b, a)); -} - #undef clipRect diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 5623dbc6bc..513aff724a 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -151,8 +151,8 @@ void Renderer::DrawSigns() { String text = currentSign.getDisplayText(sim, x, y, w, h); DrawFilledRect(RectSized(Vec2{ x + 1, y + 1 }, Vec2{ w, h - 1 }), 0x000000_rgb); - drawrect(x, y, w+1, h, 192, 192, 192, 255); - BlendText({ x+3, y+4 }, text, RGBA(255, 255, 255, 255)); + DrawRect(RectSized(Vec2{ x, y }, Vec2{ w+1, h }), 0xC0C0C0_rgb); + BlendText({ x+3, y+4 }, text, 0xFFFFFF_rgb .WithAlpha(255)); if (currentSign.ju != sign::None) { @@ -162,7 +162,7 @@ void Renderer::DrawSigns() int dy = (currentSign.y > 18) ? -1 : 1; for (int j = 0; j < 4; j++) { - blendpixel(x, y, 192, 192, 192, 255); + DrawPixel({ x, y }, 0xC0C0C0_rgb); x += dx; y += dy; } @@ -188,9 +188,9 @@ void Renderer::render_parts() for (nx=0; nx= 0 && parts[i].tmp < NPART) - draw_line(nx, ny, (int)(parts[parts[i].tmp].x+0.5f), (int)(parts[parts[i].tmp].y+0.5f), colr, colg, colb, cola); + BlendLine({ nx, ny }, { int(parts[parts[i].tmp].x+0.5f), int(parts[parts[i].tmp].y+0.5f) }, RGBA(colr, colg, colb, cola)); } } if(pixel_mode & PSPEC_STICKMAN) @@ -417,7 +417,7 @@ void Renderer::render_parts() if (mousePos.X>(nx-3) && mousePos.X<(nx+3) && mousePos.Y<(ny+3) && mousePos.Y>(ny-3)) //If mouse is in the head { String hp = String::Build(Format::Width(sim->parts[i].life, 3)); - BlendText(mousePos + Vec2{ -8-2*(sim->parts[i].life<100)-2*(sim->parts[i].life<10), -12 }, hp, RGBA(255, 255, 255, 255)); + BlendText(mousePos + Vec2{ -8-2*(sim->parts[i].life<100)-2*(sim->parts[i].life<10), -12 }, hp, 0xFFFFFF_rgb .WithAlpha(255)); } if (findingElement == t) @@ -486,23 +486,23 @@ void Renderer::render_parts() //head if(t==PT_FIGH) { - draw_line(nx, ny+2, nx+2, ny, colr, colg, colb, 255); - draw_line(nx+2, ny, nx, ny-2, colr, colg, colb, 255); - draw_line(nx, ny-2, nx-2, ny, colr, colg, colb, 255); - draw_line(nx-2, ny, nx, ny+2, colr, colg, colb, 255); + DrawLine({ nx, ny+2 }, { nx+2, ny }, RGB(colr, colg, colb)); + DrawLine({ nx+2, ny }, { nx, ny-2 }, RGB(colr, colg, colb)); + DrawLine({ nx, ny-2 }, { nx-2, ny }, RGB(colr, colg, colb)); + DrawLine({ nx-2, ny }, { nx, ny+2 }, RGB(colr, colg, colb)); } else { - draw_line(nx-2, ny+2, nx+2, ny+2, colr, colg, colb, 255); - draw_line(nx-2, ny-2, nx+2, ny-2, colr, colg, colb, 255); - draw_line(nx-2, ny-2, nx-2, ny+2, colr, colg, colb, 255); - draw_line(nx+2, ny-2, nx+2, ny+2, colr, colg, colb, 255); + DrawLine({ nx-2, ny+2 }, { nx+2, ny+2 }, RGB(colr, colg, colb)); + DrawLine({ nx-2, ny-2 }, { nx+2, ny-2 }, RGB(colr, colg, colb)); + DrawLine({ nx-2, ny-2 }, { nx-2, ny+2 }, RGB(colr, colg, colb)); + DrawLine({ nx+2, ny-2 }, { nx+2, ny+2 }, RGB(colr, colg, colb)); } //legs - draw_line(nx, ny+3, int(cplayer->legs[0]), int(cplayer->legs[1]), legr, legg, legb, 255); - draw_line(int(cplayer->legs[0]), int(cplayer->legs[1]), int(cplayer->legs[4]), int(cplayer->legs[5]), legr, legg, legb, 255); - draw_line(nx, ny+3, int(cplayer->legs[8]), int(cplayer->legs[9]), legr, legg, legb, 255); - draw_line(int(cplayer->legs[8]), int(cplayer->legs[9]), int(cplayer->legs[12]), int(cplayer->legs[13]), legr, legg, legb, 255); + DrawLine({ nx, ny+3 }, { int(cplayer->legs[ 0]), int(cplayer->legs[ 1]) }, RGB(legr, legg, legb)); + DrawLine({ int(cplayer->legs[0]), int(cplayer->legs[1]) }, { int(cplayer->legs[ 4]), int(cplayer->legs[ 5]) }, RGB(legr, legg, legb)); + DrawLine({ nx, ny+3 }, { int(cplayer->legs[ 8]), int(cplayer->legs[ 9]) }, RGB(legr, legg, legb)); + DrawLine({ int(cplayer->legs[8]), int(cplayer->legs[9]) }, { int(cplayer->legs[12]), int(cplayer->legs[13]) }, RGB(legr, legg, legb)); if (cplayer->rocketBoots) { for (int leg=0; leg<2; leg++) @@ -510,18 +510,18 @@ void Renderer::render_parts() int nx = int(cplayer->legs[leg*8+4]), ny = int(cplayer->legs[leg*8+5]); int colr = 255, colg = 0, colb = 255; if (((int)(cplayer->comm)&0x04) == 0x04 || (((int)(cplayer->comm)&0x01) == 0x01 && leg==0) || (((int)(cplayer->comm)&0x02) == 0x02 && leg==1)) - blendpixel(nx, ny, 0, 255, 0, 255); + DrawPixel({ nx, ny }, 0x00FF00_rgb); else - blendpixel(nx, ny, 255, 0, 0, 255); - blendpixel(nx+1, ny, colr, colg, colb, 223); - blendpixel(nx-1, ny, colr, colg, colb, 223); - blendpixel(nx, ny+1, colr, colg, colb, 223); - blendpixel(nx, ny-1, colr, colg, colb, 223); + DrawPixel({ nx, ny }, 0xFF0000_rgb); + BlendPixel({ nx+1, ny }, RGBA(colr, colg, colb, 223)); + BlendPixel({ nx-1, ny }, RGBA(colr, colg, colb, 223)); + BlendPixel({ nx, ny+1 }, RGBA(colr, colg, colb, 223)); + BlendPixel({ nx, ny-1 }, RGBA(colr, colg, colb, 223)); - blendpixel(nx+1, ny-1, colr, colg, colb, 112); - blendpixel(nx-1, ny-1, colr, colg, colb, 112); - blendpixel(nx+1, ny+1, colr, colg, colb, 112); - blendpixel(nx-1, ny+1, colr, colg, colb, 112); + BlendPixel({ nx+1, ny-1 }, RGBA(colr, colg, colb, 112)); + BlendPixel({ nx-1, ny-1 }, RGBA(colr, colg, colb, 112)); + BlendPixel({ nx+1, ny+1 }, RGBA(colr, colg, colb, 112)); + BlendPixel({ nx-1, ny+1 }, RGBA(colr, colg, colb, 112)); } } } @@ -531,7 +531,7 @@ void Renderer::render_parts() } if(pixel_mode & PMODE_BLEND) { - blendpixel(nx, ny, colr, colg, colb, cola); + BlendPixel({ nx, ny }, RGBA(colr, colg, colb, cola)); } if(pixel_mode & PMODE_ADD) { @@ -541,15 +541,15 @@ void Renderer::render_parts() { video[{ nx, ny }] = RGB(colr, colg, colb).Pack(); - blendpixel(nx+1, ny, colr, colg, colb, 223); - blendpixel(nx-1, ny, colr, colg, colb, 223); - blendpixel(nx, ny+1, colr, colg, colb, 223); - blendpixel(nx, ny-1, colr, colg, colb, 223); + BlendPixel({ nx+1, ny }, RGBA(colr, colg, colb, 223)); + BlendPixel({ nx-1, ny }, RGBA(colr, colg, colb, 223)); + BlendPixel({ nx, ny+1 }, RGBA(colr, colg, colb, 223)); + BlendPixel({ nx, ny-1 }, RGBA(colr, colg, colb, 223)); - blendpixel(nx+1, ny-1, colr, colg, colb, 112); - blendpixel(nx-1, ny-1, colr, colg, colb, 112); - blendpixel(nx+1, ny+1, colr, colg, colb, 112); - blendpixel(nx-1, ny+1, colr, colg, colb, 112); + BlendPixel({ nx+1, ny-1 }, RGBA(colr, colg, colb, 112)); + BlendPixel({ nx-1, ny-1 }, RGBA(colr, colg, colb, 112)); + BlendPixel({ nx+1, ny+1 }, RGBA(colr, colg, colb, 112)); + BlendPixel({ nx-1, ny+1 }, RGBA(colr, colg, colb, 112)); } if(pixel_mode & PMODE_GLOW) { @@ -582,11 +582,11 @@ void Renderer::render_parts() for (y=-3; y<4; y++) { if (abs(x)+abs(y) <2 && !(abs(x)==2||abs(y)==2)) - blendpixel(x+nx, y+ny, colr, colg, colb, 30); + BlendPixel({ x+nx, y+ny }, RGBA(colr, colg, colb, 30)); if (abs(x)+abs(y) <=3 && abs(x)+abs(y)) - blendpixel(x+nx, y+ny, colr, colg, colb, 20); + BlendPixel({ x+nx, y+ny }, RGBA(colr, colg, colb, 20)); if (abs(x)+abs(y) == 2) - blendpixel(x+nx, y+ny, colr, colg, colb, 10); + BlendPixel({ x+nx, y+ny }, RGBA(colr, colg, colb, 10)); } } } @@ -606,16 +606,16 @@ void Renderer::render_parts() { flicker = float(rng()%20); gradv = flicker + fabs(parts[i].vx)*17 + fabs(sim->parts[i].vy)*17; - blendpixel(nx, ny, colr, colg, colb, int((gradv*4)>255?255:(gradv*4)) ); - blendpixel(nx+1, ny, colr, colg, colb,int( (gradv*2)>255?255:(gradv*2)) ); - blendpixel(nx-1, ny, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) ); - blendpixel(nx, ny+1, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) ); - blendpixel(nx, ny-1, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) ); + BlendPixel({ nx, ny }, RGBA(colr, colg, colb, int((gradv*4)>255?255:(gradv*4)) )); + BlendPixel({ nx+1, ny }, RGBA(colr, colg, colb,int( (gradv*2)>255?255:(gradv*2)) )); + BlendPixel({ nx-1, ny }, RGBA(colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) )); + BlendPixel({ nx, ny+1 }, RGBA(colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) )); + BlendPixel({ nx, ny-1 }, RGBA(colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) )); if (gradv>255) gradv=255; - blendpixel(nx+1, ny-1, colr, colg, colb, int(gradv)); - blendpixel(nx-1, ny-1, colr, colg, colb, int(gradv)); - blendpixel(nx+1, ny+1, colr, colg, colb, int(gradv)); - blendpixel(nx-1, ny+1, colr, colg, colb, int(gradv)); + BlendPixel({ nx+1, ny-1 }, RGBA(colr, colg, colb, int(gradv))); + BlendPixel({ nx-1, ny-1 }, RGBA(colr, colg, colb, int(gradv))); + BlendPixel({ nx+1, ny+1 }, RGBA(colr, colg, colb, int(gradv))); + BlendPixel({ nx-1, ny+1 }, RGBA(colr, colg, colb, int(gradv))); for (x = 1; gradv>0.5; x++) { AddPixel({ nx+x, ny }, RGBA(colr, colg, colb, int(gradv))); AddPixel({ nx-x, ny }, RGBA(colr, colg, colb, int(gradv))); @@ -628,16 +628,16 @@ void Renderer::render_parts() { flicker = float(rng()%20); gradv = flicker + fabs(parts[i].vx)*17 + fabs(parts[i].vy)*17; - blendpixel(nx, ny, colr, colg, colb, int((gradv*4)>255?255:(gradv*4)) ); - blendpixel(nx+1, ny, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) ); - blendpixel(nx-1, ny, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) ); - blendpixel(nx, ny+1, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) ); - blendpixel(nx, ny-1, colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) ); + BlendPixel({ nx, ny }, RGBA(colr, colg, colb, int((gradv*4)>255?255:(gradv*4)) )); + BlendPixel({ nx+1, ny }, RGBA(colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) )); + BlendPixel({ nx-1, ny }, RGBA(colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) )); + BlendPixel({ nx, ny+1 }, RGBA(colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) )); + BlendPixel({ nx, ny-1 }, RGBA(colr, colg, colb, int((gradv*2)>255?255:(gradv*2)) )); if (gradv>255) gradv=255; - blendpixel(nx+1, ny-1, colr, colg, colb, int(gradv)); - blendpixel(nx-1, ny-1, colr, colg, colb, int(gradv)); - blendpixel(nx+1, ny+1, colr, colg, colb, int(gradv)); - blendpixel(nx-1, ny+1, colr, colg, colb, int(gradv)); + BlendPixel({ nx+1, ny-1 }, RGBA(colr, colg, colb, int(gradv))); + BlendPixel({ nx-1, ny-1 }, RGBA(colr, colg, colb, int(gradv))); + BlendPixel({ nx+1, ny+1 }, RGBA(colr, colg, colb, int(gradv))); + BlendPixel({ nx-1, ny+1 }, RGBA(colr, colg, colb, int(gradv))); for (x = 1; gradv>0.5; x++) { AddPixel({ nx+x, ny }, RGBA(colr, colg, colb, int(gradv))); AddPixel({ nx-x, ny }, RGBA(colr, colg, colb, int(gradv))); @@ -758,7 +758,7 @@ void Renderer::draw_other() // EMP effect for (j=0; j(r, g, b, a)); } } } @@ -778,9 +778,9 @@ void Renderer::draw_grav_zones() for (j=0; jgravx[ca]*0.5f; ny -= sim->gravy[ca]*0.5f; - AddPixel({ int(nx+0.5f), int(ny+0.5f) }, RGBA(255, 255, 255, (int)(dist*20.0f))); + AddPixel({ int(nx+0.5f), int(ny+0.5f) }, 0xFFFFFF_rgb .WithAlpha(int(dist*20.0f))); } } } @@ -979,8 +979,8 @@ void Renderer::DrawWalls() // there is no velocity here, draw a streamline and continue if (!xVel && !yVel) { - BlendText({ x*CELL, y*CELL-2 }, 0xE00D, RGBA(255, 255, 255, 128)); - AddPixel({ oldX, oldY }, RGBA(255, 255, 255, 255)); + BlendText({ x*CELL, y*CELL-2 }, 0xE00D, 0xFFFFFF_rgb .WithAlpha(128)); + AddPixel({ oldX, oldY }, 0xFFFFFF_rgb .WithAlpha(255)); continue; } bool changed = false; @@ -996,7 +996,7 @@ void Renderer::DrawWalls() } if (changed && (newX<0 || newX>=XRES || newY<0 || newY>=YRES)) break; - AddPixel({ newX, newY }, RGBA(255, 255, 255, 64)); + AddPixel({ newX, newY }, 0xFFFFFF_rgb .WithAlpha(64)); // cache velocity and other checks so we aren't running them constantly if (changed) { @@ -1010,7 +1010,7 @@ void Renderer::DrawWalls() xf += xVel; yf += yVel; } - BlendText({ x*CELL, y*CELL-2 }, 0xE00D, RGBA(255, 255, 255, 128)); + BlendText({ x*CELL, y*CELL-2 }, 0xE00D, 0xFFFFFF_rgb .WithAlpha(128)); } break; case 1: @@ -1054,14 +1054,14 @@ void Renderer::DrawWalls() for (int j = 0; j < CELL; j++) for (int i =0; i < CELL; i++) if (i&j&1) - drawblob((x*CELL+i), (y*CELL+j), prgb.Red, prgb.Green, prgb.Blue); + DrawBlob({ x*CELL+i, y*CELL+j }, prgb); } else { for (int j = 0; j < CELL; j++) for (int i = 0; i < CELL; i++) if (!(i&j&1)) - drawblob((x*CELL+i), (y*CELL+j), prgb.Red, prgb.Green, prgb.Blue); + DrawBlob({ x*CELL+i, y*CELL+j }, prgb); } } else if (wt == WL_WALLELEC) @@ -1070,9 +1070,9 @@ void Renderer::DrawWalls() for (int i =0; i < CELL; i++) { if (!((y*CELL+j)%2) && !((x*CELL+i)%2)) - drawblob((x*CELL+i), (y*CELL+j), prgb.Red, prgb.Green, prgb.Blue); + DrawBlob({ x*CELL+i, y*CELL+j }, prgb); else - drawblob((x*CELL+i), (y*CELL+j), 0x80, 0x80, 0x80); + DrawBlob({ x*CELL+i, y*CELL+j }, 0x808080_rgb); } } else if (wt == WL_EHOLE) @@ -1081,7 +1081,7 @@ void Renderer::DrawWalls() { for (int j = 0; j < CELL; j++) for (int i = 0; i < CELL; i++) - drawblob((x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24); + DrawBlob({ x*CELL+i, y*CELL+j }, 0x242424_rgb); for (int j = 0; j < CELL; j += 2) for (int i = 0; i < CELL; i += 2) // looks bad if drawing black blobs @@ -1091,30 +1091,30 @@ void Renderer::DrawWalls() { for (int j = 0; j < CELL; j += 2) for (int i = 0; i < CELL; i += 2) - drawblob((x*CELL+i), (y*CELL+j), 0x24, 0x24, 0x24); + DrawBlob({ x*CELL+i, y*CELL+j }, 0x242424_rgb); } } break; case 1: for (int j = 0; j < CELL; j += 2) for (int i = (j>>1)&1; i < CELL; i += 2) - drawblob((x*CELL+i), (y*CELL+j), prgb.Red, prgb.Green, prgb.Blue); + DrawBlob({ x*CELL+i, y*CELL+j }, prgb); break; case 2: for (int j = 0; j < CELL; j += 2) for (int i = 0; i < CELL; i+=2) - drawblob((x*CELL+i), (y*CELL+j), prgb.Red, prgb.Green, prgb.Blue); + DrawBlob({ x*CELL+i, y*CELL+j }, prgb); break; case 3: for (int j = 0; j < CELL; j++) for (int i = 0; i < CELL; i++) - drawblob((x*CELL+i), (y*CELL+j), prgb.Red, prgb.Green, prgb.Blue); + DrawBlob({ x*CELL+i, y*CELL+j }, prgb); break; case 4: for (int j = 0; j < CELL; j++) for (int i = 0; i < CELL; i++) if (i == j) - drawblob((x*CELL+i), (y*CELL+j), prgb.Red, prgb.Green, prgb.Blue); + DrawBlob({ x*CELL+i, y*CELL+j }, prgb); else if (i == j+1 || (i == 0 && j == CELL-1)) video[{ x * CELL + i, y * CELL + j }] = gc; else diff --git a/src/graphics/Renderer.h b/src/graphics/Renderer.h index 6a5c311507..424eb32a53 100644 --- a/src/graphics/Renderer.h +++ b/src/graphics/Renderer.h @@ -101,7 +101,7 @@ class Renderer: public RasterDrawMethods void RenderEnd(); void RenderZoom(); - void DrawBlob(int x, int y, unsigned char cr, unsigned char cg, unsigned char cb); + void DrawBlob(Vec2 pos, RGB colour); void DrawWalls(); void DrawSigns(); void render_gravlensing(const Video &source); @@ -122,8 +122,6 @@ class Renderer: public RasterDrawMethods VideoBuffer DumpFrame(); - void drawblob(int x, int y, unsigned char cr, unsigned char cg, unsigned char cb); - pixel GetPixel(Vec2 pos) const; //... //Display mode modifiers diff --git a/src/graphics/RendererBasic.cpp b/src/graphics/RendererBasic.cpp index 358f7cdffc..68b2ef3ac4 100644 --- a/src/graphics/RendererBasic.cpp +++ b/src/graphics/RendererBasic.cpp @@ -71,8 +71,8 @@ void Renderer::RenderZoom() pixel pix; DrawFilledRect(RectSized(zoomWindowPosition, { zoomScopeSize * ZFACTOR, zoomScopeSize * ZFACTOR }), 0x000000_rgb); - drawrect(zoomWindowPosition.X-2, zoomWindowPosition.Y-2, zoomScopeSize*ZFACTOR+3, zoomScopeSize*ZFACTOR+3, 192, 192, 192, 255); - drawrect(zoomWindowPosition.X-1, zoomWindowPosition.Y-1, zoomScopeSize*ZFACTOR+1, zoomScopeSize*ZFACTOR+1, 0, 0, 0, 255); + DrawRect(RectSized(zoomWindowPosition - Vec2{ 2, 2 }, Vec2{ zoomScopeSize*ZFACTOR+3, zoomScopeSize*ZFACTOR+3 }), 0xC0C0C0_rgb); + DrawRect(RectSized(zoomWindowPosition - Vec2{ 1, 1 }, Vec2{ zoomScopeSize*ZFACTOR+1, zoomScopeSize*ZFACTOR+1 }), 0x000000_rgb); for (j=0; j pos, RGB colour) { - blendpixel(x+1, y, cr, cg, cb, 112); - blendpixel(x-1, y, cr, cg, cb, 112); - blendpixel(x, y+1, cr, cg, cb, 112); - blendpixel(x, y-1, cr, cg, cb, 112); - - blendpixel(x+1, y-1, cr, cg, cb, 64); - blendpixel(x-1, y-1, cr, cg, cb, 64); - blendpixel(x+1, y+1, cr, cg, cb, 64); - blendpixel(x-1, y+1, cr, cg, cb, 64); + BlendPixel(pos + Vec2{ +1, 0 }, colour.WithAlpha(112)); + BlendPixel(pos + Vec2{ -1, 0 }, colour.WithAlpha(112)); + BlendPixel(pos + Vec2{ 0, 1 }, colour.WithAlpha(112)); + BlendPixel(pos + Vec2{ 0, -1 }, colour.WithAlpha(112)); + BlendPixel(pos + Vec2{ 1, -1 }, colour.WithAlpha(64)); + BlendPixel(pos + Vec2{ -1, -1 }, colour.WithAlpha(64)); + BlendPixel(pos + Vec2{ 1, 1 }, colour.WithAlpha(64)); + BlendPixel(pos + Vec2{ -1, +1 }, colour.WithAlpha(64)); } @@ -159,19 +158,6 @@ void Renderer::prepare_alpha(int size, float intensity) } -void Renderer::drawblob(int x, int y, unsigned char cr, unsigned char cg, unsigned char cb) -{ - blendpixel(x+1, y, cr, cg, cb, 112); - blendpixel(x-1, y, cr, cg, cb, 112); - blendpixel(x, y+1, cr, cg, cb, 112); - blendpixel(x, y-1, cr, cg, cb, 112); - - blendpixel(x+1, y-1, cr, cg, cb, 64); - blendpixel(x-1, y-1, cr, cg, cb, 64); - blendpixel(x+1, y+1, cr, cg, cb, 64); - blendpixel(x-1, y+1, cr, cg, cb, 64); -} - pixel Renderer::GetPixel(Vec2 pos) const { if (pos.X<0 || pos.Y<0 || pos.X>=VIDXRES || pos.Y>=VIDYRES) diff --git a/src/gui/colourpicker/ColourPickerActivity.cpp b/src/gui/colourpicker/ColourPickerActivity.cpp index 4afd135f95..6363172489 100644 --- a/src/gui/colourpicker/ColourPickerActivity.cpp +++ b/src/gui/colourpicker/ColourPickerActivity.cpp @@ -255,10 +255,10 @@ void ColourPickerActivity::OnKeyPress(int key, int scan, bool repeat, bool shift void ColourPickerActivity::OnDraw() { Graphics * g = GetGraphics(); - g->fillrect(Position.X-2, Position.Y-2, Size.X+3, Size.Y+3, 0, 0, 0, currentAlpha); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->BlendFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb .WithAlpha(currentAlpha)); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); - g->drawrect(Position.X+4, Position.Y+4, 258, 130, 180, 180, 180, 255); + g->DrawRect(RectSized(Position + Vec2{ 4, 4 }, Vec2{ 258, 130 }), 0xB4B4B4_rgb); auto offset = Position + Vec2{ 5, 5 }; @@ -278,7 +278,7 @@ void ColourPickerActivity::OnDraw() int cg = 0; int cb = 0; HSV_to_RGB(hue, 255-saturation, currentValue, &cr, &cg, &cb); - g->blendpixel(currx, (saturation/2)+offset.Y, cr, cg, cb, currentAlpha); + g->BlendPixel({ currx, (saturation/2)+offset.Y }, RGBA(cr, cg, cb, currentAlpha)); } } @@ -291,10 +291,9 @@ void ColourPickerActivity::OnDraw() HSV_to_RGB(hue, currentSaturation, currentValue, &red, &green, &blue); for (int ry = 0; ry < (hSlider->Size.Y / 2) - 1; ry++) { - g->blendpixel( - rx + offset.X + hSlider->Position.X, - ry + offset.Y + hSlider->Position.Y, - red, green, blue, currentAlpha + g->BlendPixel( + offset + hSlider->Position + Vec2{ rx, ry }, + RGBA(red, green, blue, currentAlpha) ); } } diff --git a/src/gui/console/ConsoleView.cpp b/src/gui/console/ConsoleView.cpp index 32a0243751..c17d1de88d 100644 --- a/src/gui/console/ConsoleView.cpp +++ b/src/gui/console/ConsoleView.cpp @@ -110,9 +110,9 @@ void ConsoleView::NotifyCurrentCommandChanged(ConsoleModel * sender) void ConsoleView::OnDraw() { Graphics * g = GetGraphics(); - g->fillrect(Position.X, Position.Y, Size.X, Size.Y, 0, 0, 0, 110); - g->draw_line(Position.X, Position.Y+Size.Y-16, Position.X+Size.X, Position.Y+Size.Y-16, 255, 255, 255, 160); - g->draw_line(Position.X, Position.Y+Size.Y, Position.X+Size.X, Position.Y+Size.Y, 255, 255, 255, 200); + g->BlendFilledRect(RectSized(Position, Size), 0x000000_rgb .WithAlpha(110)); + g->BlendLine(Position + Vec2{ 0, Size.Y-16 }, Position + Size - Vec2{ 0, 16 }, 0xFFFFFF_rgb .WithAlpha(160)); + g->BlendLine(Position + Vec2{ 0, Size.Y }, Position + Size, 0xFFFFFF_rgb .WithAlpha(200)); } void ConsoleView::OnTick(float dt) diff --git a/src/gui/dialogues/ConfirmPrompt.cpp b/src/gui/dialogues/ConfirmPrompt.cpp index 57817d6f58..7199d9fb4f 100644 --- a/src/gui/dialogues/ConfirmPrompt.cpp +++ b/src/gui/dialogues/ConfirmPrompt.cpp @@ -83,5 +83,5 @@ void ConfirmPrompt::OnDraw() Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); + g->DrawRect(RectSized(Position, Size), 0xC8C8C8_rgb); } diff --git a/src/gui/dialogues/ErrorMessage.cpp b/src/gui/dialogues/ErrorMessage.cpp index 2ea61e468f..cc6507b872 100644 --- a/src/gui/dialogues/ErrorMessage.cpp +++ b/src/gui/dialogues/ErrorMessage.cpp @@ -59,5 +59,5 @@ void ErrorMessage::OnDraw() Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); + g->DrawRect(RectSized(Position, Size), 0xC8C8C8_rgb); } diff --git a/src/gui/dialogues/InformationMessage.cpp b/src/gui/dialogues/InformationMessage.cpp index acb8828173..54407ab272 100644 --- a/src/gui/dialogues/InformationMessage.cpp +++ b/src/gui/dialogues/InformationMessage.cpp @@ -75,5 +75,5 @@ void InformationMessage::OnDraw() Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); + g->DrawRect(RectSized(Position, Size), 0xC8C8C8_rgb); } diff --git a/src/gui/dialogues/SaveIDMessage.cpp b/src/gui/dialogues/SaveIDMessage.cpp index 0f69786617..6077975b5e 100644 --- a/src/gui/dialogues/SaveIDMessage.cpp +++ b/src/gui/dialogues/SaveIDMessage.cpp @@ -53,7 +53,7 @@ void SaveIDMessage::OnDraw() Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); + g->DrawRect(RectSized(Position, Size), 0xC8C8C8_rgb); } void SaveIDMessage::OnTryExit(ExitMethod method) diff --git a/src/gui/dialogues/TextPrompt.cpp b/src/gui/dialogues/TextPrompt.cpp index 8a3aa02170..bed4925b01 100644 --- a/src/gui/dialogues/TextPrompt.cpp +++ b/src/gui/dialogues/TextPrompt.cpp @@ -94,5 +94,5 @@ void TextPrompt::OnDraw() Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); + g->DrawRect(RectSized(Position, Size), 0xC8C8C8_rgb); } diff --git a/src/gui/elementsearch/ElementSearchActivity.cpp b/src/gui/elementsearch/ElementSearchActivity.cpp index fb7e4fc2e3..0acf049b7b 100644 --- a/src/gui/elementsearch/ElementSearchActivity.cpp +++ b/src/gui/elementsearch/ElementSearchActivity.cpp @@ -213,12 +213,15 @@ void ElementSearchActivity::OnDraw() { Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); - g->drawrect(Position.X+searchField->Position.X, Position.Y+searchField->Position.Y+searchField->Size.Y+8, searchField->Size.X, Size.Y-(searchField->Position.Y+searchField->Size.Y+8)-23, 255, 255, 255, 180); + g->BlendRect( + RectSized(Position + searchField->Position + Vec2{ 0, searchField->Size.Y+8 }, + { searchField->Size.X, Size.Y-(searchField->Position.Y+searchField->Size.Y+8)-23 }), + 0xFFFFFF_rgb .WithAlpha(180)); if (toolTipPresence && toolTip.length()) { - g->BlendText({ 10, Size.Y+70 }, toolTip, RGBA(255, 255, 255, toolTipPresence>51?255:toolTipPresence*5)); + g->BlendText({ 10, Size.Y+70 }, toolTip, 0xFFFFFF_rgb .WithAlpha(toolTipPresence>51?255:toolTipPresence*5)); } } diff --git a/src/gui/filebrowser/FileBrowserActivity.cpp b/src/gui/filebrowser/FileBrowserActivity.cpp index 2ef5ee079b..5a8bf45720 100644 --- a/src/gui/filebrowser/FileBrowserActivity.cpp +++ b/src/gui/filebrowser/FileBrowserActivity.cpp @@ -304,7 +304,7 @@ void FileBrowserActivity::OnDraw() //Window Background+Outline g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); } FileBrowserActivity::~FileBrowserActivity() diff --git a/src/gui/font/FontEditor.cpp b/src/gui/font/FontEditor.cpp index 12edd0d5e6..70e4688f47 100644 --- a/src/gui/font/FontEditor.cpp +++ b/src/gui/font/FontEditor.cpp @@ -479,31 +479,31 @@ void FontEditor::OnDraw() std::array, FONT_H> const &pixels = fontPixels[currentChar]; int areaWidth = 8 + width * FONT_SCALE + 8; - g->fillrect(0, 0, areaWidth, 8 + FONT_H * FONT_SCALE + 4 + FONT_H + 4, bgR, bgG, bgB, 255); + g->DrawFilledRect(RectSized(Vec2{ 0, 0 }, Vec2{ areaWidth, 8 + FONT_H * FONT_SCALE + 4 + FONT_H + 4 }), RGB(bgR, bgG, bgB)); for(int j = 0; j < FONT_H; j++) for(int i = 0; i < width; i++) - g->fillrect(8 + i * FONT_SCALE, 8 + j * FONT_SCALE, FONT_SCALE - grid, FONT_SCALE - grid, fgR, fgG, fgB, pixels[j][i] * 255 / 3); + g->BlendFilledRect(RectSized(Vec2{ 8 + i * FONT_SCALE, 8 + j * FONT_SCALE }, Vec2{ FONT_SCALE - grid, FONT_SCALE - grid }), RGBA(fgR, fgG, fgB, pixels[j][i] * 255 / 3)); for(int j = 0; j < FONT_H; j++) for(int i = 0; i < width; i++) - g->blendpixel(8 + i, 8 + FONT_H * FONT_SCALE + 4 + j, fgR, fgG, fgB, pixels[j][i] * 255 / 3); + g->BlendPixel({ 8 + i, 8 + FONT_H * FONT_SCALE + 4 + j }, RGBA(fgR, fgG, fgB, pixels[j][i] * 255 / 3)); if(rulers) { - g->draw_line(0, 7 + 0 * FONT_SCALE , areaWidth - 1, 7 + 0 * FONT_SCALE, 128, 128, 128, 255); - g->draw_line(0, 7 + 2 * FONT_SCALE , areaWidth - 1, 7 + 2 * FONT_SCALE, 128, 128, 128, 255); - g->draw_line(0, 7 + 4 * FONT_SCALE , areaWidth - 1, 7 + 4 * FONT_SCALE, 128, 128, 128, 255); - g->draw_line(0, 7 + 9 * FONT_SCALE , areaWidth - 1, 7 + 9 * FONT_SCALE, 128, 128, 128, 255); - g->draw_line(0, 7 + 12 * FONT_SCALE , areaWidth - 1, 7 + 12 * FONT_SCALE, 128, 128, 128, 255); - - g->draw_line(7, 8, 7, 7 + FONT_H * FONT_SCALE, 128, 128, 128, 255); - g->draw_line(7 + width * FONT_SCALE, 8, 7 + width * FONT_SCALE, 7 + FONT_H * FONT_SCALE, 128, 128, 128, 255); + g->DrawLine({ 0, 7 + 0 * FONT_SCALE }, { areaWidth - 1, 7 + 0 * FONT_SCALE }, 0x808080_rgb); + g->DrawLine({ 0, 7 + 2 * FONT_SCALE }, { areaWidth - 1, 7 + 2 * FONT_SCALE }, 0x808080_rgb); + g->DrawLine({ 0, 7 + 4 * FONT_SCALE }, { areaWidth - 1, 7 + 4 * FONT_SCALE }, 0x808080_rgb); + g->DrawLine({ 0, 7 + 9 * FONT_SCALE }, { areaWidth - 1, 7 + 9 * FONT_SCALE }, 0x808080_rgb); + g->DrawLine({ 0, 7 + 12 * FONT_SCALE }, { areaWidth - 1, 7 + 12 * FONT_SCALE }, 0x808080_rgb); + + g->DrawLine({ 7, 8 }, { 7, 7 + FONT_H * FONT_SCALE }, 0x808080_rgb); + g->DrawLine({ 7 + width * FONT_SCALE, 8}, { 7 + width * FONT_SCALE, 7 + FONT_H * FONT_SCALE }, 0x808080_rgb); } } else { - g->BlendText({ 8, 8 }, "No character", RGBA(255, 0, 0, 255)); + g->BlendText({ 8, 8 }, "No character", 0xFF0000_rgb .WithAlpha(255)); } } diff --git a/src/gui/game/GOLTool.cpp b/src/gui/game/GOLTool.cpp index 74fe48d409..fec38f088c 100644 --- a/src/gui/game/GOLTool.cpp +++ b/src/gui/game/GOLTool.cpp @@ -186,7 +186,7 @@ void GOLWindow::OnDraw() Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); + g->DrawRect(RectSized(Position, Size), 0xC8C8C8_rgb); int width = Size.X - 60; for (int xx = 0; xx < width; ++xx) @@ -197,7 +197,7 @@ void GOLWindow::OnDraw() auto rr = int(highColour.Red * (1.f - f) + lowColour.Red * f); auto gg = int(highColour.Green * (1.f - f) + lowColour.Green * f); auto bb = int(highColour.Blue * (1.f - f) + lowColour.Blue * f); - g->blendpixel(Position.X + xx + 30, Position.Y + yy + 67, rr, gg, bb, 255); + g->DrawPixel(Position + Vec2{ xx + 30, yy + 67 }, RGB(rr, gg, bb)); } } } diff --git a/src/gui/game/GameView.cpp b/src/gui/game/GameView.cpp index a26f41d748..a56d0d3a36 100644 --- a/src/gui/game/GameView.cpp +++ b/src/gui/game/GameView.cpp @@ -153,7 +153,7 @@ class SplitButton : public ui::Button drawn = true; if(showSplit) - g->draw_line(splitPosition+screenPos.X, screenPos.Y+1, splitPosition+screenPos.X, screenPos.Y+Size.Y-2, 180, 180, 180, 255); + g->DrawLine(screenPos + Vec2{ splitPosition, 1 }, screenPos + Vec2{ splitPosition, Size.Y-2 }, 0xB4B4B4_rgb); } }; @@ -1838,10 +1838,10 @@ void GameView::DoDraw() 255, 195, 145, 103, 69, 42, 23, 10, 3 } }; auto *g = GetGraphics(); - for (auto x = 0U; x < fadeout.size(); ++x) + for (auto x = 0; x < int(fadeout.size()); ++x) { - g->draw_line(x, YRES + 1, x, YRES + 18, 0, 0, 0, fadeout[x]); - g->draw_line(XRES - x, YRES + 1, XRES - x, YRES + 18, 0, 0, 0, fadeout[x]); + g->BlendLine({ x, YRES + 1 }, { x, YRES + 18 }, 0x000000_rgb .WithAlpha(fadeout[x])); + g->BlendLine({ XRES - x, YRES + 1 }, { XRES - x, YRES + 18 }, 0x000000_rgb .WithAlpha(fadeout[x])); } c->Tick(); @@ -2140,7 +2140,7 @@ void GameView::OnDraw() { if(selectPoint1.X==-1) { - ren->fillrect(0, 0, XRES, YRES, 0, 0, 0, 100); + ren->BlendFilledRect(RectSized(Vec2{ 0, 0 }, Vec2{ XRES, YRES }), 0x000000_rgb .WithAlpha(100)); } else { @@ -2154,11 +2154,11 @@ void GameView::OnDraw() if(y2>YRES-1) y2 = YRES-1; - ren->fillrect(0, 0, XRES, y1, 0, 0, 0, 100); - ren->fillrect(0, y2+1, XRES, YRES-y2-1, 0, 0, 0, 100); + ren->BlendFilledRect(RectSized(Vec2{ 0, 0 }, Vec2{ XRES, y1 }), 0x000000_rgb .WithAlpha(100)); + ren->BlendFilledRect(RectSized(Vec2{ 0, y2+1 }, Vec2{ XRES, YRES-y2-1 }), 0x000000_rgb .WithAlpha(100)); - ren->fillrect(0, y1, x1, (y2-y1)+1, 0, 0, 0, 100); - ren->fillrect(x2+1, y1, XRES-x2-1, (y2-y1)+1, 0, 0, 0, 100); + ren->BlendFilledRect(RectSized(Vec2{ 0, y1 }, Vec2{ x1, (y2-y1)+1 }), 0x000000_rgb .WithAlpha(100)); + ren->BlendFilledRect(RectSized(Vec2{ x2+1, y1 }, Vec2{ XRES-x2-1, (y2-y1)+1 }), 0x000000_rgb .WithAlpha(100)); ren->XorDottedRect(RectBetween(Vec2{ x1, y1 }, Vec2{ x2, y2 })); } @@ -2199,8 +2199,8 @@ void GameView::OnDraw() break; } startY -= 14; - g->fillrect(startX-3, startY-3, Graphics::TextSize(message).X + 5, 14, 0, 0, 0, std::min(100, alpha)); - g->BlendText({ startX, startY }, message, RGBA(255, 255, 255, alpha)); + g->BlendFilledRect(RectSized(Vec2{ startX-3, startY-3 }, Vec2{ Graphics::TextSize(message).X + 5, 14 }), 0x000000_rgb .WithAlpha(std::min(100, alpha))); + g->BlendText({ startX, startY }, message, 0xFFFFFF_rgb .WithAlpha(alpha)); (*iter).second -= 3; } } @@ -2211,8 +2211,8 @@ void GameView::OnDraw() String sampleInfo = String::Build("#", screenshotIndex, " ", String(0xE00E), " REC"); int textWidth = Graphics::TextSize(sampleInfo).X - 1; - g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, 127); - g->BlendText({ XRES-16-textWidth, 16 }, sampleInfo, RGBA(255, 50, 20, 255)); + g->BlendFilledRect(RectSized(Vec2{ XRES-20-textWidth, 12 }, Vec2{ textWidth+8, 15 }), 0x000000_rgb .WithAlpha(127)); + g->BlendText({ XRES-16-textWidth, 16 }, sampleInfo, 0xFF3214_rgb .WithAlpha(255)); } else if(showHud) { @@ -2332,14 +2332,14 @@ void GameView::OnDraw() } int textWidth = Graphics::TextSize(sampleInfo.Build()).X - 1; - g->fillrect(XRES-20-textWidth, 12, textWidth+8, 15, 0, 0, 0, int(alpha*0.5f)); - g->BlendText({ XRES-16-textWidth, 16 }, sampleInfo.Build(), RGBA(255, 255, 255, int(alpha*0.75f))); + g->BlendFilledRect(RectSized(Vec2{ XRES-20-textWidth, 12 }, Vec2{ textWidth+8, 15 }), 0x000000_rgb .WithAlpha(int(alpha*0.5f))); + g->BlendText({ XRES-16-textWidth, 16 }, sampleInfo.Build(), 0xFFFFFF_rgb .WithAlpha(int(alpha*0.75f))); if (wavelengthGfx) { int i, cr, cg, cb, j, h = 3, x = XRES-19-textWidth, y = 10; int tmp; - g->fillrect(x, y, 30, h, 64, 64, 64, alpha); // coords -1 size +1 to work around bug in fillrect - TODO: fix fillrect + g->BlendFilledRect(RectSized(Vec2{ x, y }, Vec2{ 30, h }), 0x404040_rgb .WithAlpha(alpha)); for (i = 0; i < 30; i++) { if ((wavelengthGfx >> i)&1) @@ -2365,7 +2365,7 @@ void GameView::OnDraw() cg *= tmp; cb *= tmp; for (j=0; jblendpixel(x+29-i, y+j, cr>255?255:cr, cg>255?255:cg, cb>255?255:cb, alpha); + g->BlendPixel({ x+29-i, y+j }, RGBA(cr>255?255:cr, cg>255?255:cg, cb>255?255:cb, alpha)); } } } @@ -2390,8 +2390,8 @@ void GameView::OnDraw() } auto textWidth = Graphics::TextSize(sampleInfo.Build()).X - 1; - g->fillrect(XRES-20-textWidth, 27, textWidth+8, 14, 0, 0, 0, int(alpha*0.5f)); - g->BlendText({ XRES-16-textWidth, 30 }, sampleInfo.Build(), RGBA(255, 255, 255, int(alpha*0.75f))); + g->BlendFilledRect(RectSized(Vec2{ XRES-20-textWidth, 27 }, Vec2{ textWidth+8, 14 }), 0x000000_rgb .WithAlpha(int(alpha*0.5f))); + g->BlendText({ XRES-16-textWidth, 30 }, sampleInfo.Build(), 0xFFFFFF_rgb .WithAlpha(int(alpha*0.75f))); } } @@ -2419,35 +2419,35 @@ void GameView::OnDraw() int textWidth = Graphics::TextSize(fpsInfo.Build()).X - 1; int alpha = 255-introText*5; - g->fillrect(12, 12, textWidth+8, 15, 0, 0, 0, int(alpha*0.5)); - g->BlendText({ 16, 16 }, fpsInfo.Build(), RGBA(32, 216, 255, int(alpha*0.75))); + g->BlendFilledRect(RectSized(Vec2{ 12, 12 }, Vec2{ textWidth+8, 15 }), 0x000000_rgb .WithAlpha(int(alpha*0.5))); + g->BlendText({ 16, 16 }, fpsInfo.Build(), 0x20D8FF_rgb .WithAlpha(int(alpha*0.75))); } //Tooltips if(infoTipPresence) { int infoTipAlpha = (infoTipPresence>50?50:infoTipPresence)*5; - g->BlendTextOutline({ (XRES - (Graphics::TextSize(infoTip).X - 1)) / 2, YRES / 2 - 2 }, infoTip, RGBA(255, 255, 255, infoTipAlpha)); + g->BlendTextOutline({ (XRES - (Graphics::TextSize(infoTip).X - 1)) / 2, YRES / 2 - 2 }, infoTip, 0xFFFFFF_rgb .WithAlpha(infoTipAlpha)); } if(toolTipPresence && toolTipPosition.X!=-1 && toolTipPosition.Y!=-1 && toolTip.length()) { if (toolTipPosition.Y == Size.Y-MENUSIZE-10) - g->BlendTextOutline(toolTipPosition, toolTip, RGBA(255, 255, 255, toolTipPresence>51?255:toolTipPresence*5)); + g->BlendTextOutline(toolTipPosition, toolTip, 0xFFFFFF_rgb .WithAlpha(toolTipPresence>51?255:toolTipPresence*5)); else - g->BlendText(toolTipPosition, toolTip, RGBA(255, 255, 255, toolTipPresence>51?255:toolTipPresence*5)); + g->BlendText(toolTipPosition, toolTip, 0xFFFFFF_rgb .WithAlpha(toolTipPresence>51?255:toolTipPresence*5)); } if(buttonTipShow > 0) { - g->BlendText({ 16, Size.Y-MENUSIZE-24 }, buttonTip, RGBA(255, 255, 255, buttonTipShow>51?255:buttonTipShow*5)); + g->BlendText({ 16, Size.Y-MENUSIZE-24 }, buttonTip, 0xFFFFFF_rgb .WithAlpha(buttonTipShow>51?255:buttonTipShow*5)); } //Introduction text if(introText && showHud) { - g->fillrect(0, 0, WINDOWW, WINDOWH, 0, 0, 0, introText>51?102:introText*2); - g->BlendText({ 16, 16 }, introTextMessage, RGBA(255, 255, 255, introText>51?255:introText*5)); + g->BlendFilledRect(RectSized(Vec2{ 0, 0 }, WINDOW), 0x000000_rgb .WithAlpha(introText>51?102:introText*2)); + g->BlendText({ 16, 16 }, introTextMessage, 0xFFFFFF_rgb .WithAlpha(introText>51?255:introText*5)); } } diff --git a/src/gui/game/PropertyTool.cpp b/src/gui/game/PropertyTool.cpp index 6f746fb30b..6d574eca39 100644 --- a/src/gui/game/PropertyTool.cpp +++ b/src/gui/game/PropertyTool.cpp @@ -239,7 +239,7 @@ void PropertyWindow::OnDraw() Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); + g->DrawRect(RectSized(Position, Size), 0xC8C8C8_rgb); } void PropertyWindow::OnKeyPress(int key, int scan, bool repeat, bool shift, bool ctrl, bool alt) diff --git a/src/gui/game/SignTool.cpp b/src/gui/game/SignTool.cpp index 15a0f0727a..98b7d165cc 100644 --- a/src/gui/game/SignTool.cpp +++ b/src/gui/game/SignTool.cpp @@ -169,8 +169,8 @@ void SignWindow::DoDraw() String text = currentSign.getDisplayText(sim, x, y, w, h); g->DrawFilledRect(RectSized(Vec2{ x + 1, y + 1 }, Vec2{ w, h - 1 }), 0x000000_rgb); - g->drawrect(x, y, w+1, h, 192, 192, 192, 255); - g->BlendText({ x+3, y+4 }, text, RGBA(255, 255, 255, 255)); + g->DrawRect(RectSized(Vec2{ x, y }, Vec2{ w+1, h }), 0xC0C0C0_rgb); + g->BlendText({ x+3, y+4 }, text, 0xFFFFFF_rgb .WithAlpha(255)); if (currentSign.ju != sign::None) { @@ -180,7 +180,7 @@ void SignWindow::DoDraw() dy = (currentSign.y > 18) ? -1 : 1; for (int j=0; j<4; j++) { - g->blendpixel(x, y, 192, 192, 192, 255); + g->DrawPixel({ x, y }, 0xC0C0C0_rgb); x+=dx; y+=dy; } @@ -223,7 +223,7 @@ void SignWindow::OnDraw() Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); + g->DrawRect(RectSized(Position, Size), 0xC8C8C8_rgb); } std::unique_ptr SignTool::GetIcon(int toolID, Vec2 size) diff --git a/src/gui/game/ToolButton.cpp b/src/gui/game/ToolButton.cpp index d01b7c7d4d..5fafc498aa 100644 --- a/src/gui/game/ToolButton.cpp +++ b/src/gui/game/ToolButton.cpp @@ -58,16 +58,16 @@ void ToolButton::Draw(const ui::Point& screenPos) } else { - g->fillrect(screenPos.X+2, screenPos.Y+2, Size.X-4, Size.Y-4, Appearance.BackgroundInactive.Red, Appearance.BackgroundInactive.Green, Appearance.BackgroundInactive.Blue, Appearance.BackgroundInactive.Alpha); + g->BlendFilledRect(RectSized(screenPos + Vec2{ 2, 2 }, Size - Vec2{ 4, 4 }), Appearance.BackgroundInactive); } if (isMouseInside && currentSelection == -1) { - g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, Appearance.BorderActive.Red, Appearance.BorderActive.Green, Appearance.BorderActive.Blue, Appearance.BorderActive.Alpha); + g->BlendRect(RectSized(screenPos, Size), Appearance.BorderActive); } else { - g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, Appearance.BorderInactive.Red, Appearance.BorderInactive.Green, Appearance.BorderInactive.Blue, Appearance.BorderInactive.Alpha); + g->BlendRect(RectSized(screenPos, Size), Appearance.BorderInactive); } if (Favorite::Ref().IsFavorite(toolIdentifier)) { @@ -76,11 +76,11 @@ void ToolButton::Draw(const ui::Point& screenPos) if (totalColour<544) { - g->BlendText(screenPos + textPosition, buttonDisplayText, RGBA(255, 255, 255, 255)); + g->BlendText(screenPos + textPosition, buttonDisplayText, 0xFFFFFF_rgb .WithAlpha(255)); } else { - g->BlendText(screenPos + textPosition, buttonDisplayText, RGBA(0, 0, 0, 255)); + g->BlendText(screenPos + textPosition, buttonDisplayText, 0x000000_rgb .WithAlpha(255)); } if (ClipRect.Size().X && ClipRect.Size().Y) diff --git a/src/gui/interface/Button.cpp b/src/gui/interface/Button.cpp index 23492eaf8b..81155cc36e 100644 --- a/src/gui/interface/Button.cpp +++ b/src/gui/interface/Button.cpp @@ -113,19 +113,19 @@ void Button::Draw(const Point& screenPos) } bgColour = Appearance.BackgroundInactive; - g->fillrect(Position.X+1, Position.Y+1, Size.X-2, Size.Y-2, backgroundColour.Red, backgroundColour.Green, backgroundColour.Blue, backgroundColour.Alpha); + g->BlendFilledRect(RectSized(Position + Vec2{ 1, 1 }, Size - Vec2{ 2, 2 }), backgroundColour); if(Appearance.Border == 1) - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); + g->BlendRect(RectSized(Position, Size), borderColour); else { if(Appearance.Border.Top) - g->draw_line(Position.X, Position.Y, Position.X+Size.X-1, Position.Y, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); + g->BlendLine(Position + Vec2{ 0 , 0 }, Position + Vec2{ Size.X-1, 0 }, borderColour); if(Appearance.Border.Bottom) - g->draw_line(Position.X, Position.Y+Size.Y-1, Position.X+Size.X-1, Position.Y+Size.Y-1, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); + g->BlendLine(Position + Vec2{ 0 , Size.Y-1 }, Position + Vec2{ Size.X-1, Size.Y-1 }, borderColour); if(Appearance.Border.Left) - g->draw_line(Position.X, Position.Y, Position.X, Position.Y+Size.Y-1, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); + g->BlendLine(Position + Vec2{ 0 , 0 }, Position + Vec2{ 0, Size.Y-1 }, borderColour); if(Appearance.Border.Right) - g->draw_line(Position.X+Size.X-1, Position.Y, Position.X+Size.X-1, Position.Y+Size.Y-1, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); + g->BlendLine(Position + Vec2{ Size.X-1, 0 }, Position + Vec2{ Size.X-1, Size.Y-1 }, borderColour); } g->BlendText(Position + textPosition, buttonDisplayText, textColour); diff --git a/src/gui/interface/Checkbox.cpp b/src/gui/interface/Checkbox.cpp index 19924e455a..9a423e8e8e 100644 --- a/src/gui/interface/Checkbox.cpp +++ b/src/gui/interface/Checkbox.cpp @@ -76,22 +76,22 @@ void Checkbox::Draw(const Point& screenPos) Graphics * g = GetGraphics(); if(checked) { - g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 255); + g->DrawFilledRect(RectSized(screenPos + Vec2{ 5, 5 }, Vec2{ 6, 6 }), 0xFFFFFF_rgb); } if(isMouseOver) { - g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 255); - g->fillrect(screenPos.X+5, screenPos.Y+5, 6, 6, 255, 255, 255, 170); + g->DrawRect(RectSized(screenPos + Vec2{ 2, 2 }, Vec2{ 12, 12 }), 0xFFFFFF_rgb); + g->BlendFilledRect(RectSized(screenPos + Vec2{ 5, 5 }, Vec2{ 6, 6 }), 0xFFFFFF_rgb .WithAlpha(170)); if (!Appearance.icon) - g->BlendText(screenPos + Vec2{ 18, 4 }, text, RGBA(255, 255, 255, 255)); + g->BlendText(screenPos + Vec2{ 18, 4 }, text, 0xFFFFFF_rgb .WithAlpha(255)); else g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon, 255); } else { - g->drawrect(screenPos.X+2, screenPos.Y+2, 12, 12, 255, 255, 255, 200); + g->BlendRect(RectSized(screenPos + Vec2{ 2, 2 }, Vec2{ 12, 12 }), 0xFFFFFF_rgb .WithAlpha(200)); if (!Appearance.icon) - g->BlendText(screenPos + Vec2{ 18, 4 }, text, RGBA(255, 255, 255, 200)); + g->BlendText(screenPos + Vec2{ 18, 4 }, text, 0xFFFFFF_rgb .WithAlpha(200)); else g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon, 200); } diff --git a/src/gui/interface/ContextMenu.cpp b/src/gui/interface/ContextMenu.cpp index 9d1bc6f50f..a1206cb346 100644 --- a/src/gui/interface/ContextMenu.cpp +++ b/src/gui/interface/ContextMenu.cpp @@ -94,6 +94,6 @@ void ContextMenu::AddItem(ContextMenuItem item) void ContextMenu::OnDraw() { Graphics * g = GetGraphics(); - g->fillrect(Position.X, Position.Y, Size.X, Size.Y, 100, 100, 100, 255); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, Appearance.BackgroundInactive.Red, Appearance.BackgroundInactive.Green, Appearance.BackgroundInactive.Blue, Appearance.BackgroundInactive.Alpha); + g->DrawFilledRect(RectSized(Position, Size), 0x646464_rgb); + g->BlendRect(RectSized(Position, Size), Appearance.BackgroundInactive); } diff --git a/src/gui/interface/DirectionSelector.cpp b/src/gui/interface/DirectionSelector.cpp index c261ff8bfe..6fc83321b1 100644 --- a/src/gui/interface/DirectionSelector.cpp +++ b/src/gui/interface/DirectionSelector.cpp @@ -120,15 +120,16 @@ void DirectionSelector::Draw(const ui::Point& screenPos) for (auto &point : snapPoints) { - g->fillrect( - (center.X + point.offset.X) - snapPointRadius, - (center.Y + point.offset.Y) - snapPointRadius, - snapPointRadius * 2 + 1, snapPointRadius * 2 + 1, - snapPointColor.Red, snapPointColor.Green, snapPointColor.Blue, altDown ? (int)(snapPointColor.Alpha / 2) : snapPointColor.Alpha + g->BlendFilledRect( + RectBetween( + center + point.offset - Vec2{ snapPointRadius, snapPointRadius }, + center + point.offset + Vec2{ snapPointRadius, snapPointRadius } + ), + snapPointColor.NoAlpha().WithAlpha(altDown ? (int)(snapPointColor.Alpha / 2) : snapPointColor.Alpha) ); } - g->BlendFilledEllipse(center + value.offset, { handleRadius, handleRadius }, RGBA(foregroundColor.Red, foregroundColor.Green, foregroundColor.Blue, (mouseHover || mouseDown) ? std::min(int(foregroundColor.Alpha * 1.5f), 255) : foregroundColor.Alpha)); + g->BlendFilledEllipse(center + value.offset, { handleRadius, handleRadius }, foregroundColor.NoAlpha().WithAlpha((mouseHover || mouseDown) ? std::min(int(foregroundColor.Alpha * 1.5f), 255) : foregroundColor.Alpha)); g->BlendEllipse(center + value.offset, { handleRadius, handleRadius }, borderColor); } diff --git a/src/gui/interface/DropDown.cpp b/src/gui/interface/DropDown.cpp index 1a1f79155c..c1da64d117 100644 --- a/src/gui/interface/DropDown.cpp +++ b/src/gui/interface/DropDown.cpp @@ -98,8 +98,8 @@ void DropDown::Draw(const Point& screenPos) backgroundColour = Appearance.BackgroundInactive; } - g->fillrect(Position.X-1, Position.Y-1, Size.X+2, Size.Y+2, backgroundColour.Red, backgroundColour.Green, backgroundColour.Blue, backgroundColour.Alpha); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, borderColour.Red, borderColour.Green, borderColour.Blue, borderColour.Alpha); + g->BlendFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), backgroundColour); + g->BlendRect(RectSized(Position, Size), borderColour); if(optionIndex!=-1) g->BlendText(Position + textPosition, options[optionIndex].first, textColour); } diff --git a/src/gui/interface/Label.cpp b/src/gui/interface/Label.cpp index cda5b49100..c48320871d 100644 --- a/src/gui/interface/Label.cpp +++ b/src/gui/interface/Label.cpp @@ -248,39 +248,39 @@ void Label::Draw(const Point& screenPos) { if (selectionLineH == selectionLineL) { - g->fillrect( - screenPos.X + textPosition.X + selectionXL - 1, - screenPos.Y + textPosition.Y + selectionYL - 2, - selectionXH - selectionXL + 1, - FONT_H, - 255, 255, 255, 255 + g->DrawFilledRect( + RectSized( + screenPos + textPosition + Vec2{ selectionXL - 1, selectionYL - 2 }, + Vec2{ selectionXH - selectionXL + 1, FONT_H } + ), + 0xFFFFFF_rgb ); } else { - g->fillrect( - screenPos.X + textPosition.X + selectionXL - 1, - screenPos.Y + textPosition.Y + selectionYL - 2, - textSize.X - selectionXL + 1, - FONT_H, - 255, 255, 255, 255 + g->DrawFilledRect( + RectSized( + screenPos + textPosition + Vec2{ selectionXL - 1, selectionYL - 2 }, + Vec2{ textSize.X - selectionXL + 1, FONT_H } + ), + 0xFFFFFF_rgb ); for (int i = 1; i < selectionLineH - selectionLineL; ++i) { - g->fillrect( - screenPos.X + textPosition.X - 1, - screenPos.Y + textPosition.Y + selectionYL - 2 + i * FONT_H, - textSize.X + 1, - FONT_H, - 255, 255, 255, 255 + g->DrawFilledRect( + RectSized( + screenPos + textPosition + Vec2{ -1, selectionYL - 2 + i * FONT_H }, + Vec2{ textSize.X + 1, FONT_H } + ), + 0xFFFFFF_rgb ); } - g->fillrect( - screenPos.X + textPosition.X - 1, - screenPos.Y + textPosition.Y + selectionYH - 2, - selectionXH + 1, - FONT_H, - 255, 255, 255, 255 + g->DrawFilledRect( + RectSized( + screenPos + textPosition + Vec2{ -1, selectionYH - 2 }, + Vec2{ selectionXH + 1, FONT_H } + ), + 0xFFFFFF_rgb ); } } @@ -288,7 +288,7 @@ void Label::Draw(const Point& screenPos) g->BlendText( screenPos + textPosition, displayTextWithSelection, - RGBA(textColour.Red, textColour.Green, textColour.Blue, 255) + textColour.NoAlpha().WithAlpha(255) ); } diff --git a/src/gui/interface/ProgressBar.cpp b/src/gui/interface/ProgressBar.cpp index b9ce973cd5..3f474a9fce 100644 --- a/src/gui/interface/ProgressBar.cpp +++ b/src/gui/interface/ProgressBar.cpp @@ -46,7 +46,7 @@ void ProgressBar::Draw(const Point & screenPos) ui::Colour progressBarColour = style::Colour::WarningTitle; - g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); if(progress!=-1) { @@ -56,7 +56,7 @@ void ProgressBar::Draw(const Point & screenPos) progress = 100; float size = float(Size.X-4)*(float(progress)/100.0f); // TIL... size = std::min(std::max(size, 0.0f), float(Size.X-4)); - g->fillrect(screenPos.X + 2, screenPos.Y + 2, int(size), Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255); + g->DrawFilledRect(RectSized(screenPos + Vec2{ 2, 2 }, Vec2{ int(size), Size.Y-4 }), progressBarColour.NoAlpha()); } } else { int size = 40, rsize = 0; @@ -66,13 +66,13 @@ void ProgressBar::Draw(const Point & screenPos) size = int((Size.X-4)-position+1); rsize = 40-size; } - g->fillrect(screenPos.X + 2 + int(position), screenPos.Y + 2, size, Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255); + g->DrawFilledRect(RectSized(screenPos + Vec2{ 2 + int(position), 2 }, Vec2{ size, Size.Y-4 }), progressBarColour.NoAlpha()); if(rsize) { - g->fillrect(screenPos.X + 2, screenPos.Y + 2, rsize, Size.Y-4, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255); + g->DrawFilledRect(RectSized(screenPos + Vec2{ 2, 2 }, Vec2{ rsize, Size.Y-4 }), progressBarColour.NoAlpha()); } } - g->BlendText(screenPos + Vec2{ ((Size.X-(Graphics::TextSize(progressStatus).X - 1))/2), (Size.Y-8)/2 }, progressStatus, progress<50 ? RGBA(255, 255, 255, 255) : RGBA(0, 0, 0, 255)); + g->BlendText(screenPos + Vec2{ ((Size.X-(Graphics::TextSize(progressStatus).X - 1))/2), (Size.Y-8)/2 }, progressStatus, progress<50 ? 0xFFFFFF_rgb .WithAlpha(255) : 0x000000_rgb .WithAlpha(255)); } void ProgressBar::Tick(float dt) diff --git a/src/gui/interface/RichLabel.cpp b/src/gui/interface/RichLabel.cpp index 22c9e80dce..efa6a7d5f9 100644 --- a/src/gui/interface/RichLabel.cpp +++ b/src/gui/interface/RichLabel.cpp @@ -179,7 +179,7 @@ void RichLabel::Draw(const Point& screenPos) { Graphics * g = GetGraphics(); ui::Colour textColour = Appearance.TextInactive; - g->BlendText(screenPos + textPosition, displayText, RGBA(textColour.Red, textColour.Green, textColour.Blue, 255)); + g->BlendText(screenPos + textPosition, displayText, textColour.NoAlpha().WithAlpha(255)); } void RichLabel::OnMouseClick(int x, int y, unsigned button) diff --git a/src/gui/interface/SaveButton.cpp b/src/gui/interface/SaveButton.cpp index f2ffae0bd0..34d6a79822 100644 --- a/src/gui/interface/SaveButton.cpp +++ b/src/gui/interface/SaveButton.cpp @@ -188,7 +188,7 @@ void SaveButton::Draw(const Point& screenPos) if(selected && selectable) { - g->fillrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 100, 170, 255, 100); + g->BlendFilledRect(RectSized(screenPos, Size), 0x64AAFF_rgb .WithAlpha(100)); } if (thumbnail) @@ -199,77 +199,63 @@ void SaveButton::Draw(const Point& screenPos) g->BlendImage(tex->Data(), 255, RectSized(screenPos + ((save && save->id) ? ((space - thumbBoxSize) / 2 - Vec2{ 3, 0 }) : (space - thumbSize) / 2), tex->Size())); } else if (file && !file->GetGameSave()) - g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize("Error loading save").X - 1))/2, (Size.Y-28)/2 }, "Error loading save", RGBA(180, 180, 180, 255)); + g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize("Error loading save").X - 1))/2, (Size.Y-28)/2 }, "Error loading save", 0xB4B4B4_rgb .WithAlpha(255)); if(save) { if(save->id) { - if(isMouseInside) - { - g->drawrect(screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 210, 230, 255, 255); - g->drawrect(screenPos.X-4+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, 7, thumbBoxSize.Y, 210, 230, 255, 255); - } - else - { - g->drawrect(screenPos.X-3+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 180, 180, 180, 255); - g->drawrect(screenPos.X-4+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, 7, thumbBoxSize.Y, 180, 180, 180, 255); - } + g->DrawRect(RectSized(screenPos + Vec2{ - 3, 0 } + (Size - thumbBoxSize - Vec2{ 0, 21 }) / 2, thumbBoxSize), isMouseInside ? 0xD2E6FF_rgb : 0xB4B4B4_rgb); + g->DrawRect(RectSized(screenPos + Vec2{ thumbBoxSize.X - 4, 0 } + (Size - thumbBoxSize - Vec2{ 0, 21 }) / 2, Vec2{ 7, thumbBoxSize.Y }), isMouseInside ? 0xD2E6FF_rgb : 0xB4B4B4_rgb); - g->fillrect(screenPos.X-3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+1+(Size.Y-20-thumbBoxSize.Y)/2, 5, (thumbBoxSize.Y+1)/2-1, 0, 107, 10, 255); - g->fillrect(screenPos.X-3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-20)/2, 5, thumbBoxSize.Y/2-1, 107, 10, 0, 255); + g->DrawFilledRect(RectSized(screenPos + Vec2{ -3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, 1+(Size.Y-20-thumbBoxSize.Y)/2 }, Vec2{ 5, (thumbBoxSize.Y+1)/2-1 }), 0x006B0A_rgb); + g->DrawFilledRect(RectSized(screenPos + Vec2{ -3+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, (Size.Y-20)/2 }, Vec2{ 5, thumbBoxSize.Y/2-1 }), 0x6B0A00_rgb); - g->fillrect(screenPos.X-2+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-20)/2-voteBarHeightUp, 3, voteBarHeightUp, 57, 187, 57, 255); //green - g->fillrect(screenPos.X-2+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-20)/2, 3, voteBarHeightDown, 187, 57, 57, 255); //red + g->DrawFilledRect(RectSized(screenPos + Vec2{ -2+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, (Size.Y-20)/2-voteBarHeightUp }, Vec2{ 3, voteBarHeightUp }), 0x39BB39_rgb); //green + g->DrawFilledRect(RectSized(screenPos + Vec2{ -2+thumbBoxSize.X+(Size.X-thumbBoxSize.X)/2, (Size.Y-20)/2 }, Vec2{ 3, voteBarHeightDown }), 0xBB3939_rgb); //red } else { - if(isMouseInside) - g->drawrect(screenPos.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 210, 230, 255, 255); - else - g->drawrect(screenPos.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 180, 180, 180, 255); + g->DrawRect(RectSized(screenPos + (Size - thumbBoxSize - Vec2{ 0, 21 }) / 2, thumbBoxSize), isMouseInside ? 0xD2E6FF_rgb : 0xB4B4B4_rgb); } - g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize(name).X - 1))/2, Size.Y - 21 }, name, (isMouseInside && !isMouseInsideAuthor) ? RGBA(255, 255, 255, 255) : RGBA(180, 180, 180, 255)); - g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize(save->userName.FromUtf8()).X - 1))/2, Size.Y - 10 }, save->userName.FromUtf8(), isMouseInsideAuthor ? RGBA(200, 230, 255, 255) : RGBA(100, 130, 160, 255)); + g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize(name).X - 1))/2, Size.Y - 21 }, name, (isMouseInside && !isMouseInsideAuthor) ? 0xFFFFFF_rgb .WithAlpha(255) : 0xB4B4B4_rgb .WithAlpha(255)); + g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize(save->userName.FromUtf8()).X - 1))/2, Size.Y - 10 }, save->userName.FromUtf8(), isMouseInsideAuthor ? 0xC8E6FF_rgb .WithAlpha(255) : 0x6482A0_rgb .WithAlpha(255)); if (showVotes)// && !isMouseInside) { int x = screenPos.X-7+(Size.X-thumbBoxSize.X)/2+thumbBoxSize.X-(Graphics::TextSize(votesBackground).X - 1); int y = screenPos.Y-23+(Size.Y-thumbBoxSize.Y)/2+thumbBoxSize.Y; - g->BlendText({ x, y }, votesBackground, RGBA(16, 72, 16, 255)); - g->BlendText({ x, y }, votesBackground2, RGBA(192, 192, 192, 255)); - g->BlendText({ x+3, y }, votesString, RGBA(255, 255, 255, 255)); + g->BlendText({ x, y }, votesBackground, 0x104810_rgb .WithAlpha(255)); + g->BlendText({ x, y }, votesBackground2, 0xC0C0C0_rgb .WithAlpha(255)); + g->BlendText({ x+3, y }, votesString, 0xFFFFFF_rgb .WithAlpha(255)); } if (isMouseInsideHistory && showVotes) { int x = screenPos.X; int y = screenPos.Y-15+(Size.Y-thumbBoxSize.Y)/2+thumbBoxSize.Y; - g->fillrect(x+1, y+1, 7, 8, 255, 255, 255, 255); - g->BlendText({ x, y }, 0xE026, isMouseInsideHistory ? RGBA(200, 100, 80, 255) : RGBA(160, 70, 50, 255)); + g->DrawFilledRect(RectSized(Vec2{ x+1, y+1 }, Vec2{ 7, 8 }), 0xFFFFFF_rgb); + g->BlendText({ x, y }, 0xE026, isMouseInsideHistory ? 0xC86450_rgb .WithAlpha(255) : 0xA04632_rgb .WithAlpha(255)); } if (!save->GetPublished()) { - g->BlendText(screenPos - Vec2{ 0, 2 }, 0xE04D, RGBA(255, 255, 255, 255)); - g->BlendText(screenPos - Vec2{ 0, 2 }, 0xE04E, RGBA(212, 151, 81, 255)); + g->BlendText(screenPos - Vec2{ 0, 2 }, 0xE04D, 0xFFFFFF_rgb .WithAlpha(255)); + g->BlendText(screenPos - Vec2{ 0, 2 }, 0xE04E, 0xD49751_rgb .WithAlpha(255)); } } else if (file) { - if (isMouseInside) - g->drawrect(screenPos.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 210, 230, 255, 255); - else - g->drawrect(screenPos.X+(Size.X-thumbBoxSize.X)/2, screenPos.Y+(Size.Y-21-thumbBoxSize.Y)/2, thumbBoxSize.X, thumbBoxSize.Y, 180, 180, 180, 255); + g->DrawRect(RectSized(screenPos + (Size - thumbBoxSize- Vec2{ 0, 21 }) / 2, thumbBoxSize), isMouseInside ? 0xD2E6FF_rgb : 0xB4B4B4_rgb); if (thumbSize.X) g->XorDottedRect(RectSized(screenPos + (Size - thumbSize - Vec2{ 0, 21 }) / 2, thumbSize)); - g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize(name).X - 1))/2, Size.Y - 21 }, name, isMouseInside ? RGBA(255, 255, 255, 255) : RGBA(180, 180, 180, 255)); + g->BlendText(screenPos + Vec2{ (Size.X-(Graphics::TextSize(name).X - 1))/2, Size.Y - 21 }, name, isMouseInside ? 0xFFFFFF_rgb .WithAlpha(255) : 0xB4B4B4_rgb .WithAlpha(255)); } if(isMouseInside && selectable) { g->DrawFilledRect(RectSized(screenPos + Vec2{ Size.X - 19, 7 }, Vec2{ 13, 13 }), 0x000000_rgb); - g->drawrect(screenPos.X+(Size.X-20), screenPos.Y+6, 14, 14, 255, 255, 255, 255); + g->DrawRect(RectSized(screenPos + Vec2{ Size.X-20, 6 }, Vec2{ 14, 14 }), 0xFFFFFF_rgb); if(selected) - g->fillrect(screenPos.X+(Size.X-18), screenPos.Y+8, 10, 10, 255, 255, 255, 255); + g->DrawFilledRect(RectSized(screenPos + Vec2{ Size.X-18, 8 }, Vec2{ 10, 10 }), 0xFFFFFF_rgb); } } diff --git a/src/gui/interface/ScrollPanel.cpp b/src/gui/interface/ScrollPanel.cpp index b190c23d0a..9814d44a87 100644 --- a/src/gui/interface/ScrollPanel.cpp +++ b/src/gui/interface/ScrollPanel.cpp @@ -65,8 +65,8 @@ void ScrollPanel::Draw(const Point& screenPos) scrollPos = float(Size.Y-scrollHeight)*(float(offsetY)/float(maxOffset.Y)); } - g->fillrect(screenPos.X+(Size.X-scrollBarWidth), screenPos.Y, scrollBarWidth, Size.Y, 125, 125, 125, 100); - g->fillrect(screenPos.X+(Size.X-scrollBarWidth), screenPos.Y+int(scrollPos), scrollBarWidth, int(scrollHeight)+1, 255, 255, 255, 255); + g->BlendFilledRect(RectSized(screenPos + Vec2{ Size.X - scrollBarWidth, 0 }, { scrollBarWidth, Size.Y }), 0x7D7D7D_rgb .WithAlpha(100)); + g->DrawFilledRect(RectSized(screenPos + Vec2{ Size.X - scrollBarWidth, int(scrollPos) }, { scrollBarWidth, int(scrollHeight)+1 }), 0xFFFFFF_rgb); } } diff --git a/src/gui/interface/Slider.cpp b/src/gui/interface/Slider.cpp index 0247534d39..eac1c9ad8a 100644 --- a/src/gui/interface/Slider.cpp +++ b/src/gui/interface/Slider.cpp @@ -104,7 +104,6 @@ void Slider::SetSteps(int steps) void Slider::Draw(const Point& screenPos) { Graphics * g = GetGraphics(); - //g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255); if (bgGradient.size()) { @@ -112,13 +111,12 @@ void Slider::Draw(const Point& screenPos) { for (int i = 3; i < Size.X-7; i++) { - RGB color = bgGradient[i - 3]; - g->blendpixel(screenPos.X+i+2, screenPos.Y+j+2, color.Red, color.Green, color.Blue, 255); + g->DrawPixel(screenPos + Vec2{ i + 2, j + 2 }, bgGradient[i - 3]); } } } - g->drawrect(screenPos.X+3, screenPos.Y+3, Size.X-6, Size.Y-6, 255, 255, 255, 255); + g->DrawRect(RectSized(screenPos + Vec2{ 3, 3 }, Size - Vec2{ 6, 6 }), 0xFFFFFF_rgb); auto fPosition = float(sliderPosition); auto fSize = float(Size.X-6); @@ -128,8 +126,8 @@ void Slider::Draw(const Point& screenPos) auto sliderX = int(fSliderX); sliderX += 3; - g->fillrect(screenPos.X+sliderX-2, screenPos.Y+1, 4, Size.Y-2, 20, 20, 20, 255); - g->drawrect(screenPos.X+sliderX-2, screenPos.Y+1, 4, Size.Y-2, 200, 200, 200, 255); + g->DrawFilledRect(RectSized(screenPos + Vec2{ sliderX-2, 1 }, Vec2{ 4, Size.Y-2 }), 0x141414_rgb); + g->DrawRect(RectSized(screenPos + Vec2{ sliderX-2, 1 }, Vec2{ 4, Size.Y-2 }), 0xC8C8C8_rgb); } } /* namespace ui */ diff --git a/src/gui/interface/Spinner.cpp b/src/gui/interface/Spinner.cpp index 990bfc1a4a..3a145f3333 100644 --- a/src/gui/interface/Spinner.cpp +++ b/src/gui/interface/Spinner.cpp @@ -27,8 +27,10 @@ void Spinner::Draw(const Point& screenPos) int lineOuter = (Size.X/2)+3; for(float t = 0.0f; t < 6.0f; t+=0.25f) { - //g->drawblob(baseX+(sin(cValue+t)*(Size.X/2)), baseY+(cos(cValue+t)*(Size.X/2)), t*255, t*255, t*255); - g->draw_line(int(baseX+(sin(cValue+t)*lineInner)), int(baseY+(cos(cValue+t)*lineInner)), int(baseX+(sin(cValue+t)*lineOuter)), int(baseY+(cos(cValue+t)*lineOuter)), int((t/6)*255), int((t/6)*255), int((t/6)*255), 255); + g->DrawLine( + { int(baseX+(sin(cValue+t)*lineInner)), int(baseY+(cos(cValue+t)*lineInner)) }, + { int(baseX+(sin(cValue+t)*lineOuter)), int(baseY+(cos(cValue+t)*lineOuter)) }, + RGB(int((t/6)*255), int((t/6)*255), int((t/6)*255))); } } Spinner::~Spinner() diff --git a/src/gui/interface/Textbox.cpp b/src/gui/interface/Textbox.cpp index 27fed1b7fd..3b5da792a2 100644 --- a/src/gui/interface/Textbox.cpp +++ b/src/gui/interface/Textbox.cpp @@ -613,16 +613,21 @@ void Textbox::Draw(const Point& screenPos) Graphics * g = GetGraphics(); if(IsFocused()) { - if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 255); - g->draw_line(screenPos.X+textPosition.X+cursorPositionX, screenPos.Y-2+textPosition.Y+cursorPositionY, screenPos.X+textPosition.X+cursorPositionX, screenPos.Y+9+textPosition.Y+cursorPositionY, 255, 255, 255, 255); + if(border) + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); + g->DrawLine( + screenPos + textPosition + Vec2{ cursorPositionX, cursorPositionY-2 }, + screenPos + textPosition + Vec2{ cursorPositionX, cursorPositionY+9 }, + 0xFFFFFF_rgb); } else { if(!text.length()) { - g->BlendText(screenPos + textPosition, placeHolder, RGBA(textColour.Red, textColour.Green, textColour.Blue, 170)); + g->BlendText(screenPos + textPosition, placeHolder, textColour.NoAlpha().WithAlpha(170)); } - if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255); + if(border) + g->DrawRect(RectSized(Position, Size), 0xA0A0A0_rgb); } if(Appearance.icon) g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon); diff --git a/src/gui/login/LoginView.cpp b/src/gui/login/LoginView.cpp index be6d3b5ac3..befb214b80 100644 --- a/src/gui/login/LoginView.cpp +++ b/src/gui/login/LoginView.cpp @@ -125,7 +125,7 @@ void LoginView::OnDraw() { Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); } LoginView::~LoginView() { diff --git a/src/gui/options/OptionsView.cpp b/src/gui/options/OptionsView.cpp index 6a75d825b8..8b30901ccd 100644 --- a/src/gui/options/OptionsView.cpp +++ b/src/gui/options/OptionsView.cpp @@ -46,7 +46,7 @@ OptionsView::OptionsView(): void Draw(const ui::Point& screenPos) override { - GetGraphics()->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 255, 255, 255, 180); + GetGraphics()->BlendRect(RectSized(screenPos, Size), 0xFFFFFF_rgb .WithAlpha(180)); } }; @@ -159,7 +159,7 @@ OptionsView::OptionsView(): Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255); + g->DrawRect(RectSized(Position, Size), 0xC8C8C8_rgb); } ui::DirectionSelector * gravityDirection; @@ -541,7 +541,7 @@ void OptionsView::OnDraw() { Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); } void OptionsView::OnTryExit(ExitMethod method) diff --git a/src/gui/preview/PreviewView.cpp b/src/gui/preview/PreviewView.cpp index 94bdb3ae49..a7e190df72 100644 --- a/src/gui/preview/PreviewView.cpp +++ b/src/gui/preview/PreviewView.cpp @@ -260,21 +260,18 @@ void PreviewView::DoDraw() { int linePos = commentTextComponents[i]->Position.Y+commentsPanel->ViewportPosition.Y+commentTextComponents[i]->Size.Y+4; if (linePos > 0 && linePos < Size.Y-commentBoxHeight) - g->draw_line( - Position.X+1+XRES/2, - Position.Y+linePos, - Position.X+Size.X-2, - Position.Y+linePos, - 255, 255, 255, 100); + g->BlendLine( + Position + Vec2{ 1+XRES/2, linePos }, + Position + Vec2{ Size.X-2, linePos }, + 0xFFFFFF_rgb .WithAlpha(100)); } if (c->GetDoOpen()) { - g->fillrect(Position.X+(Size.X/2)-101, Position.Y+(Size.Y/2)-26, 202, 52, 0, 0, 0, 210); - g->drawrect(Position.X+(Size.X/2)-100, Position.Y+(Size.Y/2)-25, 200, 50, 255, 255, 255, 180); - // g->BlendText(Position + Vec2{(Size.X/2)-((Graphics::TextSize(ByteString("加载沙盘中...").X - 1).FromUtf8())/2), (Size.Y/2)-5},ByteString("加载沙盘中...").FromUtf8(), RGBA(style::Colour::InformationTitle.Red, style::Colour::InformationTitle.Green, style::Colour::InformationTitle.Blue, 255)); - g->BlendText(Position + Vec2{(Size.X/2)-((Graphics::TextSize(ByteString("加载沙盘中...").FromUtf8()).X - 1)/2), (Size.Y/2)-5}, ByteString("加载沙盘中...").FromUtf8(), RGBA(style::Colour::InformationTitle.Red, style::Colour::InformationTitle.Green, style::Colour::InformationTitle.Blue, 255)); + g->BlendFilledRect(RectSized(Position + Size / 2 - Vec2{ 101, 26 }, { 202, 52 }), 0x000000_rgb .WithAlpha(210)); + g->BlendRect(RectSized(Position + Size / 2 - Vec2{ 100, 25 }, Vec2{ 200, 50 }), 0xFFFFFF_rgb .WithAlpha(180)); + g->BlendText(Position + Vec2{(Size.X/2)-((Graphics::TextSize(ByteString("加载沙盘中...").FromUtf8()).X - 1)/2), (Size.Y/2)-5}, ByteString("加载沙盘中...").FromUtf8(), style::Colour::InformationTitle.NoAlpha().WithAlpha(255)); } - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); } @@ -290,8 +287,8 @@ void PreviewView::OnDraw() { g->BlendImage(savePreview->Data(), 0xFF, RectSized(Position + Vec2(1, 1) + (RES / 2 - savePreview->Size()) / 2, savePreview->Size())); } - g->drawrect(Position.X, Position.Y, (XRES/2)+1, (YRES/2)+1, 255, 255, 255, 100); - g->draw_line(Position.X+XRES/2, Position.Y+1, Position.X+XRES/2, Position.Y+Size.Y-2, 200, 200, 200, 255); + g->BlendRect(RectSized(Position, RES / 2 + Vec2{ 1, 1 }), 0xFFFFFF_rgb .WithAlpha(100)); + g->DrawLine(Position + Vec2{ XRES/2, 1 }, Position + Vec2{ XRES/2, Size.Y-2 }, 0xC8C8C8_rgb); if(votesUp || votesDown) { @@ -315,13 +312,13 @@ void PreviewView::OnDraw() nyu = nyu>50?50:nyu; nyd = nyd>50?50:nyd; - g->fillrect(Position.X+(XRES/2)-55, Position.Y+(YRES/2)+3, 53, 7, 0, 107, 10, 255); - g->fillrect(Position.X+(XRES/2)-55, Position.Y+(YRES/2)+9, 53, 7, 107, 10, 0, 255); - g->drawrect(Position.X+(XRES/2)-55, Position.Y+(YRES/2)+3, 53, 7, 128, 128, 128, 255); - g->drawrect(Position.X+(XRES/2)-55, Position.Y+(YRES/2)+9, 53, 7, 128, 128, 128, 255); + g->DrawFilledRect(RectSized(Position + RES / 2 + Vec2{ -55, 3 }, Vec2{ 53, 7 }), 0x006B0A_rgb); + g->DrawFilledRect(RectSized(Position + RES / 2 + Vec2{ -55, 9 }, Vec2{ 53, 7 }), 0x6B0A00_rgb); + g->DrawRect(RectSized(Position + Vec2{ (XRES/2)-55, (YRES/2)+3 }, { 53, 7 }), 0x808080_rgb); + g->DrawRect(RectSized(Position + Vec2{ (XRES/2)-55, (YRES/2)+9 }, { 53, 7 }), 0x808080_rgb); - g->fillrect(Position.X+(XRES/2)-4-nyu, Position.Y+(YRES/2)+5, nyu, 3, 57, 187, 57, 255); - g->fillrect(Position.X+(XRES/2)-4-nyd, Position.Y+(YRES/2)+11, nyd, 3, 187, 57, 57, 255); + g->DrawFilledRect(RectSized(Position + RES / 2 + Vec2{ -4-nyu, 5 }, Vec2{ nyu, 3 }), 0x39BB39_rgb); + g->DrawFilledRect(RectSized(Position + RES / 2 + Vec2{ -4-nyd, 11 }, Vec2{ nyd, 3 }), 0xBB3939_rgb); } } diff --git a/src/gui/profile/ProfileActivity.cpp b/src/gui/profile/ProfileActivity.cpp index 38211e4c10..4c3e711b8f 100644 --- a/src/gui/profile/ProfileActivity.cpp +++ b/src/gui/profile/ProfileActivity.cpp @@ -233,7 +233,7 @@ void ProfileActivity::OnDraw() { Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); } void ProfileActivity::OnTryExit(ExitMethod method) diff --git a/src/gui/render/RenderView.cpp b/src/gui/render/RenderView.cpp index 2e603fd7f7..9435fe7048 100644 --- a/src/gui/render/RenderView.cpp +++ b/src/gui/render/RenderView.cpp @@ -169,15 +169,15 @@ void RenderView::OnDraw() ren->RenderBegin(); ren->RenderEnd(); } - g->draw_line(0, YRES, XRES - 1, YRES, 200, 200, 200, 255); - g->draw_line(line1, YRES, line1, WINDOWH, 200, 200, 200, 255); - g->draw_line(line2, YRES, line2, WINDOWH, 200, 200, 200, 255); - g->draw_line(line3, YRES, line3, WINDOWH, 200, 200, 200, 255); - g->draw_line(line4, YRES, line4, WINDOWH, 200, 200, 200, 255); - g->draw_line(XRES, 0, XRES, WINDOWH, 255, 255, 255, 255); - if (toolTipPresence && toolTip.length()) + g->DrawLine({ 0, YRES }, { XRES-1, YRES }, 0xC8C8C8_rgb); + g->DrawLine({ line1, YRES }, { line1, WINDOWH }, 0xC8C8C8_rgb); + g->DrawLine({ line2, YRES }, { line2, WINDOWH }, 0xC8C8C8_rgb); + g->DrawLine({ line3, YRES }, { line3, WINDOWH }, 0xC8C8C8_rgb); + g->DrawLine({ line4, YRES }, { line4, WINDOWH }, 0xC8C8C8_rgb); + g->DrawLine({ XRES, 0 }, { XRES, WINDOWH }, 0xFFFFFF_rgb); + if(toolTipPresence && toolTip.length()) { - g->BlendText({ 6, Size.Y-MENUSIZE-12 }, toolTip, RGBA(255, 255, 255, toolTipPresence>51?255:toolTipPresence*5)); + g->BlendText({ 6, Size.Y-MENUSIZE-12 }, toolTip, 0xFFFFFF_rgb .WithAlpha(toolTipPresence>51?255:toolTipPresence*5)); } } diff --git a/src/gui/search/SearchController.cpp b/src/gui/search/SearchController.cpp index edca49cfb6..df62a7ec00 100644 --- a/src/gui/search/SearchController.cpp +++ b/src/gui/search/SearchController.cpp @@ -206,7 +206,7 @@ void SearchController::OpenSave(int saveID) { delete activePreview; Graphics * g = searchView->GetGraphics(); - g->fillrect(XRES/3, WINDOWH-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable + g->BlendFilledRect(RectSized(Vec2{ XRES/3, WINDOWH-20 }, Vec2{ XRES/3, 20 }), 0x000000_rgb .WithAlpha(150)); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable activePreview = new PreviewController(saveID, 0, instantOpen, [this] { OpenSaveDone(); }); activePreview->GetView()->MakeActiveWindow(); } @@ -215,7 +215,7 @@ void SearchController::OpenSave(int saveID, int saveDate) { delete activePreview; Graphics * g = searchView->GetGraphics(); - g->fillrect(XRES/3, WINDOWH-20, XRES/3, 20, 0, 0, 0, 150); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable + g->BlendFilledRect(RectSized(Vec2{ XRES/3, WINDOWH-20 }, Vec2{ XRES/3, 20 }), 0x000000_rgb .WithAlpha(150)); //dim the "Page X of Y" a little to make the CopyTextButton more noticeable activePreview = new PreviewController(saveID, saveDate, instantOpen, [this] { OpenSaveDone(); }); activePreview->GetView()->MakeActiveWindow(); } diff --git a/src/gui/tags/TagsView.cpp b/src/gui/tags/TagsView.cpp index cf0de1c0d8..1e4fc0e00e 100644 --- a/src/gui/tags/TagsView.cpp +++ b/src/gui/tags/TagsView.cpp @@ -53,7 +53,7 @@ void TagsView::OnDraw() { Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); } void TagsView::NotifyTagsChanged(TagsModel * sender) diff --git a/src/lua/LegacyLuaAPI.cpp b/src/lua/LegacyLuaAPI.cpp index 0e5ec6aaec..e82ceba91e 100644 --- a/src/lua/LegacyLuaAPI.cpp +++ b/src/lua/LegacyLuaAPI.cpp @@ -891,7 +891,7 @@ int luatpt_drawpixel(lua_State* l) else if (b>255) b = 255; if (a<0) a = 0; else if (a>255) a = 255; - luacon_g->blendpixel(x, y, r, g, b, a); + luacon_g->BlendPixel({ x, y }, RGBA(r, g, b, a)); return 0; } @@ -921,7 +921,14 @@ int luatpt_drawrect(lua_State* l) else if (b>255) b = 255; if (a<0) a = 0; else if (a>255) a = 255; - luacon_g->drawrect(x, y, w, h, r, g, b, a); + if (a == 255) + { + luacon_g->DrawRect(RectSized(Vec2{ x, y }, Vec2{ w, h }), RGB(r, g, b)); + } + else + { + luacon_g->BlendRect(RectSized(Vec2{ x, y }, Vec2{ w, h }), RGBA(r, g, b, a)); + } return 0; } @@ -951,7 +958,14 @@ int luatpt_fillrect(lua_State* l) else if (b>255) b = 255; if (a<0) a = 0; else if (a>255) a = 255; - luacon_g->fillrect(x, y, w, h, r, g, b, a); + if (a == 255) + { + luacon_g->DrawFilledRect(RectSized(Vec2{ x, y }, Vec2{ w, h }), RGB(r, g, b)); + } + else + { + luacon_g->BlendFilledRect(RectSized(Vec2{ x, y }, Vec2{ w, h }), RGBA(r, g, b, a)); + } return 0; } @@ -976,7 +990,14 @@ int luatpt_drawline(lua_State* l) else if (b>255) b = 255; if (a<0) a = 0; else if (a>255) a = 255; - luacon_g->draw_line(x1, y1, x2, y2, r, g, b, a); + if (a == 255) + { + luacon_g->DrawLine({ x1, y1 }, { x2, y2 }, RGB(r, g, b)); + } + else + { + luacon_g->BlendLine({ x1, y1 }, { x2, y2 }, RGBA(r, g, b, a)); + } return 0; } diff --git a/src/lua/LuaScriptInterface.cpp b/src/lua/LuaScriptInterface.cpp index 4602d96949..58fdb0dd3c 100644 --- a/src/lua/LuaScriptInterface.cpp +++ b/src/lua/LuaScriptInterface.cpp @@ -3836,7 +3836,14 @@ int LuaScriptInterface::graphics_drawLine(lua_State * l) if (a<0) a = 0; else if (a>255) a = 255; - luacon_g->draw_line(x1, y1, x2, y2, r, g, b, a); + if (a == 255) + { + luacon_g->DrawLine({ x1, y1 }, { x2, y2 }, RGB(r, g, b)); + } + else + { + luacon_g->BlendLine({ x1, y1 }, { x2, y2 }, RGBA(r, g, b, a)); + } return 0; } @@ -3860,7 +3867,14 @@ int LuaScriptInterface::graphics_drawRect(lua_State * l) if (a<0) a = 0; else if (a>255) a = 255; - luacon_g->drawrect(x, y, width, height, r, g, b, a); + if (a == 255) + { + luacon_g->DrawRect(RectSized(Vec2{ x, y }, Vec2{ width, height }), RGB(r, g, b)); + } + else + { + luacon_g->BlendRect(RectSized(Vec2{ x, y }, Vec2{ width, height }), RGBA(r, g, b, a)); + } return 0; } @@ -3884,7 +3898,14 @@ int LuaScriptInterface::graphics_fillRect(lua_State * l) if (a<0) a = 0; else if (a>255) a = 255; - luacon_g->fillrect(x, y, width, height, r, g, b, a); + if (a == 255) + { + luacon_g->DrawFilledRect(RectSized(Vec2{ x, y }, Vec2{ width, height }), RGB(r, g, b)); + } + else + { + luacon_g->BlendFilledRect(RectSized(Vec2{ x, y }, Vec2{ width, height }), RGBA(r, g, b, a)); + } return 0; } diff --git a/src/lua/LuaWindow.cpp b/src/lua/LuaWindow.cpp index 2b21d72c95..5608048d47 100644 --- a/src/lua/LuaWindow.cpp +++ b/src/lua/LuaWindow.cpp @@ -81,7 +81,7 @@ LuaWindow::LuaWindow(lua_State * l) : { Graphics * g = ui::Engine::Ref().g; g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); luaWindow->triggerOnDraw(); } void OnInitialized() override { luaWindow->triggerOnInitialized(); } diff --git a/src/tasks/TaskWindow.cpp b/src/tasks/TaskWindow.cpp index 4ea78900b2..448cf309dd 100644 --- a/src/tasks/TaskWindow.cpp +++ b/src/tasks/TaskWindow.cpp @@ -87,9 +87,9 @@ void TaskWindow::OnDraw() { Graphics * g = GetGraphics(); g->DrawFilledRect(RectSized(Position - Vec2{ 1, 1 }, Size + Vec2{ 2, 2 }), 0x000000_rgb); - g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 255, 255, 255, 255); + g->DrawRect(RectSized(Position, Size), 0xFFFFFF_rgb); - g->draw_line(Position.X, Position.Y + Size.Y-17, Position.X + Size.X - 1, Position.Y + Size.Y-17, 255, 255, 255, 255); + g->DrawLine(Position + Vec2{ 0, Size.Y-17 }, Position + Vec2{ Size.X - 1, Size.Y-17 }, 0xFFFFFF_rgb); ui::Colour progressBarColour = style::Colour::WarningTitle; @@ -101,7 +101,7 @@ void TaskWindow::OnDraw() progress = 100; float size = float(Size.X-4)*(float(progress)/100.0f); // TIL... size = std::min(std::max(size, 0.0f), float(Size.X-4)); - g->fillrect(Position.X + 2, Position.Y + Size.Y-15, int(size), 13, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255); + g->DrawFilledRect(RectSized(Position + Vec2{ 2, Size.Y-15 }, Vec2{ int(size), 13 }), progressBarColour.NoAlpha()); } } else { int size = 40, rsize = 0; @@ -111,13 +111,13 @@ void TaskWindow::OnDraw() size = (Size.X-4)-int(position)+1; rsize = 40-size; } - g->fillrect(Position.X + 2 + int(position), Position.Y + Size.Y-15, size, 13, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255); + g->DrawFilledRect(RectSized(Position + Vec2{ 2 + int(position), Size.Y-15 }, Vec2{ size, 13 }), progressBarColour.NoAlpha()); if(rsize) { - g->fillrect(Position.X + 2, Position.Y + Size.Y-15, rsize, 13, progressBarColour.Red, progressBarColour.Green, progressBarColour.Blue, 255); + g->DrawFilledRect(RectSized(Position + Vec2{ 2, Size.Y-15 }, Vec2{ rsize, 13 }), progressBarColour.NoAlpha()); } } - g->BlendText(Position + Vec2{ ((Size.X-(Graphics::TextSize(progressStatus).X - 1))/2), Size.Y-13 }, progressStatus, progress<50 ? RGBA(255, 255, 255, 255) : RGBA(0, 0, 0, 255)); + g->BlendText(Position + Vec2{ ((Size.X-(Graphics::TextSize(progressStatus).X - 1))/2), Size.Y-13 }, progressStatus, progress<50 ? 0xFFFFFF_rgb .WithAlpha(255) : 0x000000_rgb .WithAlpha(255)); } TaskWindow::~TaskWindow() {