op/paint: remove support for PaintOp.Rect

PaintOp.Rect is the wrong abstraction; it implies a clip operation
better handled by package clip, and not all paints need it (colors).
Furthermore, it's awkward to specify a PaintOp that fills up the
current clip area, regardless of its size.

Redefine PathOp to mean "fill current clip area".

API change. Replace uses of PaintOp.Rect with a TransformOp applied
before the PaintOp.

Leave a TODO for the PathOp infinity area.

Fixes gio#167

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-11-05 16:09:55 +01:00
parent afb52194d1
commit 94d242d18c
19 changed files with 93 additions and 106 deletions
+1 -2
View File
@@ -5,7 +5,6 @@ package widget
import (
"image"
"gioui.org/f32"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/clip"
@@ -36,7 +35,7 @@ func (im Image) Layout(gtx layout.Context) layout.Dimensions {
stack := op.Push(gtx.Ops)
clip.Rect(image.Rectangle{Max: d}).Add(gtx.Ops)
im.Src.Add(gtx.Ops)
paint.PaintOp{Rect: f32.Rectangle{Max: f32.Point{X: float32(w), Y: float32(h)}}}.Add(gtx.Ops)
paint.PaintOp{}.Add(gtx.Ops)
stack.Pop()
return layout.Dimensions{Size: d}
}