clip: change Rect argument to f32.Rectangle

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-11-09 19:42:19 +01:00
parent 4f30b985eb
commit 65c783179d
3 changed files with 21 additions and 5 deletions
+11 -3
View File
@@ -284,9 +284,17 @@ func (p *Path) End() Op {
}
}
// Rect returns the clip area of a pixel aligned rectangular area.
func Rect(r image.Rectangle) Op {
return Op{bounds: toRectF(r)}
// Rect returns the clip area of a rectangle.
func Rect(ops *op.Ops, r f32.Rectangle) Op {
ri := image.Rectangle{
Min: image.Point{X: int(r.Min.X), Y: int(r.Min.Y)},
Max: image.Point{X: int(r.Max.X), Y: int(r.Max.Y)},
}
// Optimize pixel-aligned rectangles to just its bounds.
if r == toRectF(ri) {
return Op{bounds: r}
}
return RoundRect(ops, r, 0, 0, 0, 0)
}
// RoundRect returns the clip area of a rectangle with rounded