op/clip: move Rect to shapes.go

It's a specialized shape like the others.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2021-01-19 20:31:29 +01:00
parent d93874005c
commit cd47a158a2
2 changed files with 18 additions and 16 deletions
-16
View File
@@ -387,19 +387,3 @@ func (o Outline) Op() Op {
outline: true,
}
}
// Rect represents the clip area of a pixel-aligned rectangle.
type Rect image.Rectangle
// Op returns the op for the rectangle.
func (r Rect) Op() Op {
return Op{
bounds: image.Rectangle(r),
outline: true,
}
}
// Add the clip operation.
func (r Rect) Add(ops *op.Ops) {
r.Op().Add(ops)
}
+18
View File
@@ -3,10 +3,28 @@
package clip
import (
"image"
"gioui.org/f32"
"gioui.org/op"
)
// Rect represents the clip area of a pixel-aligned rectangle.
type Rect image.Rectangle
// Op returns the op for the rectangle.
func (r Rect) Op() Op {
return Op{
bounds: image.Rectangle(r),
outline: true,
}
}
// Add the clip operation.
func (r Rect) Add(ops *op.Ops) {
r.Op().Add(ops)
}
// UniformRRect returns an RRect with all corner radii set to the
// provided radius.
func UniformRRect(rect f32.Rectangle, radius float32) RRect {