From 5ae01e206d8e37b8588aeffe0d6151d0f1930207 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sat, 21 Jul 2018 23:00:26 +0900 Subject: [PATCH] Fix premultiplying on rounded rectangles --- lib/graphics.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/graphics.c b/lib/graphics.c index 9531966c..14dad4ec 100644 --- a/lib/graphics.c +++ b/lib/graphics.c @@ -743,13 +743,14 @@ void draw_rounded_rectangle(gfx_context_t * ctx, int32_t x, int32_t y, uint16_t radius = height / 2; } + uint32_t c = premultiply(color); for (int row = y; row < y + height; row++){ for (int col = x; col < x + width; col++) { if ((col < x + radius || col > x + width - radius - 1) && (row < y + radius || row > y + height - radius - 1)) { continue; } - GFX(ctx, col, row) = alpha_blend_rgba(GFX(ctx, col, row), color); + GFX(ctx, col, row) = alpha_blend_rgba(GFX(ctx, col, row), c); } } @@ -767,7 +768,7 @@ void draw_rounded_rectangle(gfx_context_t * ctx, int32_t x, int32_t y, uint16_t uint32_t c = color; if (j == (int)j_max) { - c = rgba(_RED(c),_BLU(c),_GRE(c),(int)((double)_ALP(c) * (j_max - (double)j))); + c = premultiply(rgba(_RED(c),_BLU(c),_GRE(c),(int)((double)_ALP(c) * (j_max - (double)j)))); } GFX(ctx, _x, _y) = alpha_blend_rgba(GFX(ctx, _x, _y), c);