mirror of
https://github.com/baketnk/frame-yap.git
synced 2026-10-06 01:00:04 +02:00
Match external handles to the panel gradient
This commit is contained in:
1 parent
434d6b3951
commit
50f5277f5c
2 files changed
+25
No files matched your search
@@ -353,6 +353,17 @@ struct PanelSurface::Impl {
|
||||
rounded({400, 721, 200, 6}, 3, handle, handle);
|
||||
rounded({1008, 721, 36, 6}, 3, handle, handle);
|
||||
rounded({1038, 691, 6, 36}, 3, handle, handle);
|
||||
// Give each handle the same full mint-to-blue theme gradient as the
|
||||
// main frame, without changing its antialiased alpha coverage.
|
||||
for (Rect bounds : {Rect{400, 721, 200, 6}, Rect{1008, 691, 36, 36}})
|
||||
for (int y = bounds.y; y < bounds.y + bounds.h; ++y)
|
||||
for (int x = bounds.x; x < bounds.x + bounds.w; ++x) {
|
||||
auto* dst = pixels.data() + (size_t(y) * W + x) * 4;
|
||||
if (!dst[3]) continue;
|
||||
const auto color = mix(theme.frame_start, theme.frame_end,
|
||||
float(x - bounds.x) / (bounds.w - 1));
|
||||
std::copy_n(color.begin(), 3, dst);
|
||||
}
|
||||
dirty = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,20 @@ int main(int argc, char** argv) {
|
||||
assert(alpha(500, 690) == 0 && alpha(1030, 704) == 0);
|
||||
// Antialiased handle edges carry real alpha, not RGB hidden at alpha zero.
|
||||
assert(alpha(401, 721) > 0 && alpha(401, 721) < 255);
|
||||
// Both external handles use the configured full frame gradient, not a
|
||||
// fixed blue or a tint that fills in their transparent surroundings.
|
||||
Theme gradient_theme;
|
||||
gradient_theme.frame_start = {255, 0, 0, 255};
|
||||
gradient_theme.frame_end = {0, 0, 255, 255};
|
||||
PanelSurface gradient_surface(argv[1], Mount::World, gradient_theme);
|
||||
gradient_surface.render(p);
|
||||
const auto channel = [&](int x, int y, int c) {
|
||||
return gradient_surface.pixels()[(y * PanelSurface::width + x) * 4 + c];
|
||||
};
|
||||
assert(channel(410, 723, 0) > 230 && channel(590, 723, 2) > 230);
|
||||
assert(channel(1012, 723, 0) > 220 && channel(1040, 705, 2) > 220);
|
||||
assert(channel(1030, 704, 3) == 0 && channel(800, 724, 3) == 0);
|
||||
assert(channel(401, 721, 3) == alpha(401, 721));
|
||||
|
||||
p.enabled = true;
|
||||
p.record_available = false;
|
||||
|
||||
Reference in new issue
Block a user