From 8242234274a274985a59a74066f36c6930d9f9cc Mon Sep 17 00:00:00 2001 From: Walter Werner SCHNEIDER Date: Mon, 6 May 2024 00:47:39 +0300 Subject: [PATCH] internal/stroke: fix normal vector size With this change the GPU renderer now properly handles the cases when the stroke width equals the stroke length where the normal vector is the same size as the original vector. Fixes: https://todo.sr.ht/~eliasnaur/gio/576 Signed-off-by: Walter Werner SCHNEIDER --- internal/stroke/stroke.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/stroke/stroke.go b/internal/stroke/stroke.go index 43752898..1a647de5 100644 --- a/internal/stroke/stroke.go +++ b/internal/stroke/stroke.go @@ -327,6 +327,9 @@ func strokePathNorm(p0, p1, p2 f32.Point, t, d float32) f32.Point { func rot90CW(p f32.Point) f32.Point { return f32.Pt(+p.Y, -p.X) } func normPt(p f32.Point, l float32) f32.Point { + if (p.X == 0 && p.Y == l) || (p.Y == 0 && p.X == l) { + return f32.Point{X: p.X, Y: p.Y} + } d := math.Hypot(float64(p.X), float64(p.Y)) l64 := float64(l) if math.Abs(d-l64) < 1e-10 {