mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
internal/stroke: fix normal vector size and direction
The normal vector size and direction depend on the input point and the sign of the unit value provided. Fixes: https://todo.sr.ht/~eliasnaur/gio/576 Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
This commit is contained in:
committed by
Elias Naur
parent
c3ce484b5e
commit
6ce7ffa4ca
@@ -327,8 +327,14 @@ 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}
|
||||
isVerticalUnit := p.X == 0 && (p.Y == l || p.Y == -l)
|
||||
isHorizontalUnit := p.Y == 0 && (p.X == l || p.X == -l)
|
||||
if isVerticalUnit || isHorizontalUnit {
|
||||
if math.Signbit(float64(l)) {
|
||||
return f32.Point{X: -p.X, Y: -p.Y}
|
||||
} else {
|
||||
return f32.Point{X: p.X, Y: p.Y}
|
||||
}
|
||||
}
|
||||
d := math.Hypot(float64(p.X), float64(p.Y))
|
||||
l64 := float64(l)
|
||||
|
||||
Reference in New Issue
Block a user