From c44a47acb1be83197bd73f19a199909567d40214 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 3 Jul 2021 02:49:20 +0300 Subject: [PATCH] gg: fix draw_line on macos (native rendering) --- vlib/gg/gg.v | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/vlib/gg/gg.v b/vlib/gg/gg.v index 8f7013b57a..a15b2beb53 100644 --- a/vlib/gg/gg.v +++ b/vlib/gg/gg.v @@ -638,10 +638,23 @@ pub fn (mut ctx Context) resize(width int, height int) { // draw_line draws a line between the points provided pub fn (ctx &Context) draw_line(x f32, y f32, x2 f32, y2 f32, c gx.Color) { + $if macos { + if ctx.native_rendering { + // Make the line more clear on hi dpi screens: draw a rectangle + mut width := math.abs(x2 - x) + mut height := math.abs(y2 - y) + if width == 0 { + width = 1 + } else if height == 0 { + height = 1 + } + ctx.draw_rect(x, y, f32(width), f32(height), c) + return + } + } if c.a != 255 { sgl.load_pipeline(ctx.timage_pip) } - sgl.c4b(c.r, c.g, c.b, c.a) sgl.begin_line_strip() sgl.v2f(x * ctx.scale, y * ctx.scale)