internal/stroke: handle zero-length points

Fixes the edge case where a zero point would be normalized to NaN.

Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
This commit is contained in:
Walter Werner SCHNEIDER
2025-07-28 22:08:33 +03:00
committed by Elias Naur
parent 36a2fa37c7
commit 176570527d
2 changed files with 7 additions and 0 deletions
+4
View File
@@ -16,6 +16,10 @@ func TestNormPt(t *testing.T) {
}
scenarios := []scenario{
// l!=0 && X=Y=0
{l: 10, ptIn: f32.Point{X: 0, Y: 0}, ptOut: f32.Point{X: 0, Y: 0}},
{l: -10, ptIn: f32.Point{X: 0, Y: 0}, ptOut: f32.Point{X: 0, Y: 0}},
// l>0 & X
{l: +20, ptIn: f32.Point{X: +30, Y: 0}, ptOut: f32.Point{X: +20, Y: 0}},
{l: +20, ptIn: f32.Point{X: +20, Y: 0}, ptOut: f32.Point{X: +20, Y: 0}},