f32: handle empty rectangles in Union and Intersect

The old renderer depends on the old behaviour of Union, so change that
reference to a copy.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-04-08 18:53:21 +02:00
parent d51d8b46c3
commit 3322e211c9
2 changed files with 27 additions and 1 deletions
+18 -1
View File
@@ -93,5 +93,22 @@ func (qs *quadSplitter) splitAndEncode(quad stroke.QuadSegment) {
}
}
qs.bounds = qs.bounds.Union(cbnd)
qs.bounds = unionRect(qs.bounds, cbnd)
}
// Union is like f32.Rectangle.Union but ignores empty rectangles.
func unionRect(r, s f32.Rectangle) f32.Rectangle {
if r.Min.X > s.Min.X {
r.Min.X = s.Min.X
}
if r.Min.Y > s.Min.Y {
r.Min.Y = s.Min.Y
}
if r.Max.X < s.Max.X {
r.Max.X = s.Max.X
}
if r.Max.Y < s.Max.Y {
r.Max.Y = s.Max.Y
}
return r
}