mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
clip: add Path method to Rect
Useful when drawing non-rounded rectangles with Stroke. Also, this makes it consistent with RRect and Circle which also have a Path method. Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
+9
-4
@@ -18,10 +18,7 @@ type Rect image.Rectangle
|
||||
func (r Rect) Op() Op {
|
||||
return Op{
|
||||
outline: true,
|
||||
path: PathSpec{
|
||||
shape: ops.Rect,
|
||||
bounds: image.Rectangle(r),
|
||||
},
|
||||
path: r.Path(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +27,14 @@ func (r Rect) Push(ops *op.Ops) Stack {
|
||||
return r.Op().Push(ops)
|
||||
}
|
||||
|
||||
// Path returns the PathSpec for the rectangle.
|
||||
func (r Rect) Path() PathSpec {
|
||||
return PathSpec{
|
||||
shape: ops.Rect,
|
||||
bounds: image.Rectangle(r),
|
||||
}
|
||||
}
|
||||
|
||||
// UniformRRect returns an RRect with all corner radii set to the
|
||||
// provided radius.
|
||||
func UniformRRect(rect f32.Rectangle, radius float32) RRect {
|
||||
|
||||
Reference in New Issue
Block a user