From 3f25a49c7554d0f7a67b94d2a94ba728fd87f966 Mon Sep 17 00:00:00 2001 From: Pierre Curto Date: Thu, 4 Nov 2021 21:02:51 +0100 Subject: [PATCH] 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 --- op/clip/shapes.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/op/clip/shapes.go b/op/clip/shapes.go index 456cf191..e8acb6a5 100644 --- a/op/clip/shapes.go +++ b/op/clip/shapes.go @@ -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 {