Draw checkers for transparent color in ui::color_view

This commit is contained in:
Nikita Lisitsa 2022-12-20 18:19:05 +03:00
parent 8e0c27c8c0
commit 17bb412140

View file

@ -29,7 +29,28 @@ namespace psemek::ui
box[1] = geom::expand(geom::interval<float>::singleton(box[1].center()), box[0].length() / 2.f);
}
p.draw_rect(box, color_);
if (color_[3] != 255)
{
p.draw_rect(box, {255, 255, 255, 255});
int const n = 4;
geom::vector<float, 2> d = box.dimensions() / (n * 1.f);
for (int x = 0; x < n; ++x)
{
for (int y = 0; y < n; ++y)
{
if ((x + y) % 2 == 0) continue;
auto origin = box.corner(0.f, 0.f) + geom::pointwise_mult(d, {x * 1.f, y});
p.draw_rect(geom::span(origin, origin + d), {191, 191, 191, 255});
}
}
}
if (color_[3] != 0)
p.draw_rect(box, color_);
}
}