From 7eb5dd41097d2bbc2b8c8d7f19ffc239dc5aad07 Mon Sep 17 00:00:00 2001 From: Dmitry Sapozhnikov <11535558+o-sdn-o@users.noreply.github.com> Date: Fri, 24 May 2024 03:06:39 +0500 Subject: [PATCH] #571 WIP: Rotate colored glyphs --- src/netxs/desktopio/gui.hpp | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/src/netxs/desktopio/gui.hpp b/src/netxs/desktopio/gui.hpp index 590e46895..940ff6455 100644 --- a/src/netxs/desktopio/gui.hpp +++ b/src/netxs/desktopio/gui.hpp @@ -36,10 +36,10 @@ namespace netxs::gui .add("👩🏾‍👨🏾‍👧🏾‍👧🏾", vss<21>, ", ", ", ", ", " 😃", vss<21,21>, ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", ", "{}; + static constexpr auto l0 = std::to_array({ 1, -1, -1, 1, -1, 1, 1, -1 }); + static constexpr auto l1 = std::to_array({ 1, 1, -1, -1, 1, 1, -1, -1 }); buffer.assign(glyph_mask.bits.begin(), glyph_mask.bits.end()); - //if (glyph_mask.type == sprite::color) + auto xform = [&](auto elem) { - using yyy = byte;//irgb; - auto count = buffer.size() / sizeof(yyy); - auto src = netxs::raster{ std::span{ (yyy*)buffer.data(), count }, glyph_mask.area }; + using type = decltype(elem); + auto count = buffer.size() / sizeof(type); + auto src = netxs::raster{ std::span{ (type*)buffer.data(), count }, glyph_mask.area }; auto mx = glyph_mask.area.size.x; auto my = glyph_mask.area.size.y; if (swapxy) @@ -751,25 +753,11 @@ namespace netxs::gui std::swap(glyph_mask.area.size.x, glyph_mask.area.size.y); std::swap(glyph_mask.area.coor.x, glyph_mask.area.coor.y); } - auto dst = glyph_mask.raster(); + auto dst = glyph_mask.raster(); auto s__dx = 1; auto s__dy = mx; auto dmx = glyph_mask.area.size.x; auto dmy = glyph_mask.area.size.y; - //auto lut = std::to_array( - //{ - // std::tuple{ 1, dmx, 0, 0 }, // 1 0 00 - // std::tuple{ -dmx, 1, 0, dmy - 1 }, // 2 0 01 - // std::tuple{ -1, -dmx, dmx - 1, dmy - 1 }, // 3 0 10 - // std::tuple{ dmx, -1, dmx - 1, 0 }, // 4 0 11 - // std::tuple{ -1, dmx, dmx - 1, 0 }, // 5 1 00 - // std::tuple{ dmx, 1, 0, 0 }, // 6 1 01 - // std::tuple{ 1, -dmx, 0, dmy - 1 }, // 7 1 10 - // std::tuple{ -dmx, -1, dmx - 1, dmy - 1 }, // 8 1 11 - //}); - //auto [d__dx, d__dy, d__px, d__py] = lut[flipandrotate]; - static constexpr auto l0 = std::to_array({ 1, -1, -1, 1, -1, 1, 1, -1 }); - static constexpr auto l1 = std::to_array({ 1, 1, -1, -1, 1, 1, -1, -1 }); auto sx = l0[flipandrotate]; auto sy = l1[flipandrotate]; auto d__dx = sx * ((flipandrotate & 0b1) ? dmx : 1); @@ -803,7 +791,8 @@ namespace netxs::gui d_eol += d__dy; } } - } + }; + glyph_mask.type == sprite::color ? xform(irgb{}) : xform(byte{}); } } void draw_cell(auto& canvas, twod coor, cell const& c)