From 56e947bb44dd654634bb068c0a11f173fdd85114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 1 Jan 2021 12:47:57 +0100 Subject: [PATCH] box-drawing: LIGHT ARC: pixel-perfect At least in odd-sized cells, with a thickness of 1 pixel. --- box-drawing.c | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/box-drawing.c b/box-drawing.c index 0e2bcb7b..d2666d65 100644 --- a/box-drawing.c +++ b/box-drawing.c @@ -1067,59 +1067,61 @@ draw_box_drawings_light_arc(wchar_t wc, uint8_t *buf, int width, int height, int if (wc == L'╭') { start_x = hw; start_y = height - 1; + end_x = width - 1; end_y = hh; c1_x = hw; - c1_y = round(3. * height / 4.); + c1_y = 3. * height / 4.; c2_x = hw; - c2_y = hh + 1; + c2_y = hh; } else if (wc == L'╮') { - start_x = 0; - start_y = hh; - end_x = hw; - end_y = height - 1; + start_x = hw; + start_y = height - 1; - c1_x = hw + 1; - c1_y = hh + 1; + end_x = 0; + end_y = hh; - c2_x = hw + 1; - c2_y = round(3. * height / 4.); + c1_x = hw; + c1_y = 3. * height / 4.; + + c2_x = hw; + c2_y = hh; } else if (wc == L'╯') { - start_x = 0; - start_y = hh; - end_x = hw; - end_y = 0; + start_x = hw; + start_y = 0; - c1_x = hw + 2; - c1_y = hh + 1; + end_x = 0; + end_y = hh; - c2_x = hw + 1; - c2_y = round(height / 4.); + c1_x = hw; + c1_y = height / 4.; + + c2_x = hw; + c2_y = hh; } else { assert(wc == L'╰'); start_x = hw; start_y = 0; + end_x = width - 1; end_y = hh; c1_x = hw; - c1_y = round(height / 4.); + c1_y = height / 4.; c2_x = hw; - c2_y = hh + 1; + c2_y = hh; } - LOG_INFO("%f, %f", round(3. * height / 4.), round(height / 4.)); - int num_samples = height * 4; for (size_t i = 0; i < num_samples + 1; i++) { double t = (double)i / num_samples; - int p_x = cubic_bezier_x(t); - int p_y = cubic_bezier_y(t); + int p_x = round(cubic_bezier_x(t)); + int p_y = round(cubic_bezier_y(t)); for (int y = max(p_y - delta, 0); y < min(p_y + delta + extra, height); y++) { for (int x = max(p_x - delta, 0); x < min(p_x + delta + extra, width); x++) {