diff --git a/op/clip/shapes.go b/op/clip/shapes.go index e8acb6a5..46b9e88e 100644 --- a/op/clip/shapes.go +++ b/op/clip/shapes.go @@ -158,10 +158,14 @@ func (e Ellipse) Push(ops *op.Ops) Stack { // path constructs a path for the ellipse. func (e Ellipse) path(o *op.Ops) PathSpec { + bounds := f32.Rectangle(e) + if bounds.Dx() == 0 || bounds.Dy() == 0 { + return PathSpec{shape: ops.Rect} + } + var p Path p.Begin(o) - bounds := f32.Rectangle(e) center := bounds.Max.Add(bounds.Min).Mul(.5) diam := bounds.Dx() r := diam * .5 diff --git a/op/clip/shapes_test.go b/op/clip/shapes_test.go new file mode 100644 index 00000000..9e502ba6 --- /dev/null +++ b/op/clip/shapes_test.go @@ -0,0 +1,18 @@ +package clip_test + +import ( + "image/color" + "testing" + + "gioui.org/f32" + "gioui.org/op" + "gioui.org/op/clip" + "gioui.org/op/paint" +) + +func TestZeroEllipse(t *testing.T) { + p := f32.Pt(1.0, 2.0) + e := clip.Ellipse{Min: p, Max: p} + ops := new(op.Ops) + paint.FillShape(ops, color.NRGBA{R: 255, A: 255}, e.Op(ops)) +}