mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-03 16:35:36 +00:00
all: remove redundant op.TransformOp.Offset
Use op.Offset instead, or create and manipulate a f32.Affine2D.
API change. Update your code with a gofmt rule:
gofmt -r 'op.TransformOp{}.Offset -> op.Offset'
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -87,7 +87,7 @@ func BenchmarkDrawUI(b *testing.B) {
|
||||
|
||||
p := op.Push(gtx.Ops)
|
||||
off := float32(math.Mod(float64(i)/10, 10))
|
||||
op.TransformOp{}.Offset(f32.Pt(off, off)).Add(gtx.Ops)
|
||||
op.Offset(f32.Pt(off, off)).Add(gtx.Ops)
|
||||
|
||||
drawCore(gtx, th)
|
||||
|
||||
@@ -157,14 +157,14 @@ func draw1000Circles(gtx layout.Context) {
|
||||
ops := gtx.Ops
|
||||
for x := 0; x < 100; x++ {
|
||||
p := op.Push(ops)
|
||||
op.TransformOp{}.Offset(f32.Pt(float32(x*10), 0)).Add(ops)
|
||||
op.Offset(f32.Pt(float32(x*10), 0)).Add(ops)
|
||||
for y := 0; y < 10; y++ {
|
||||
pi := op.Push(ops)
|
||||
paint.ColorOp{Color: color.RGBA{R: 100 + uint8(x), G: 100 + uint8(y), B: 100, A: 120}}.Add(ops)
|
||||
clip.Rect{Rect: f32.Rect(0, 0, 10, 10), NE: 5, SE: 5, SW: 5, NW: 5}.Add(ops)
|
||||
paint.PaintOp{Rect: f32.Rect(0, 0, 10, 10)}.Add(ops)
|
||||
pi.Pop()
|
||||
op.TransformOp{}.Offset(f32.Pt(0, float32(100))).Add(ops)
|
||||
op.Offset(f32.Pt(0, float32(100))).Add(ops)
|
||||
}
|
||||
p.Pop()
|
||||
}
|
||||
@@ -180,13 +180,13 @@ func draw1000CirclesInstanced(gtx layout.Context) {
|
||||
|
||||
for x := 0; x < 100; x++ {
|
||||
p := op.Push(ops)
|
||||
op.TransformOp{}.Offset(f32.Pt(float32(x*10), 0)).Add(ops)
|
||||
op.Offset(f32.Pt(float32(x*10), 0)).Add(ops)
|
||||
for y := 0; y < 10; y++ {
|
||||
pi := op.Push(ops)
|
||||
paint.ColorOp{Color: color.RGBA{R: 100 + uint8(x), G: 100 + uint8(y), B: 100, A: 120}}.Add(ops)
|
||||
c.Add(ops)
|
||||
pi.Pop()
|
||||
op.TransformOp{}.Offset(f32.Pt(0, float32(100))).Add(ops)
|
||||
op.Offset(f32.Pt(0, float32(100))).Add(ops)
|
||||
}
|
||||
p.Pop()
|
||||
}
|
||||
@@ -209,14 +209,14 @@ func drawIndividualShapes(gtx layout.Context, th *material.Theme) chan op.CallOp
|
||||
c := op.Record(ops)
|
||||
for x := 0; x < 9; x++ {
|
||||
p := op.Push(ops)
|
||||
op.TransformOp{}.Offset(f32.Pt(float32(x*50), 0)).Add(ops)
|
||||
op.Offset(f32.Pt(float32(x*50), 0)).Add(ops)
|
||||
for y := 0; y < 9; y++ {
|
||||
pi := op.Push(ops)
|
||||
paint.ColorOp{Color: color.RGBA{R: 100 + uint8(x), G: 100 + uint8(y), B: 100, A: 120}}.Add(ops)
|
||||
clip.Rect{Rect: f32.Rect(0, 0, 25, 25), NE: 10, SE: 10, SW: 10, NW: 10}.Add(ops)
|
||||
paint.PaintOp{Rect: f32.Rect(0, 0, 25, 25)}.Add(ops)
|
||||
pi.Pop()
|
||||
op.TransformOp{}.Offset(f32.Pt(0, float32(50))).Add(ops)
|
||||
op.Offset(f32.Pt(0, float32(50))).Add(ops)
|
||||
}
|
||||
p.Pop()
|
||||
}
|
||||
@@ -241,7 +241,7 @@ func drawShapeInstances(gtx layout.Context, th *material.Theme) chan op.CallOp {
|
||||
for x := 0; x < 20; x++ {
|
||||
for y := 0; y < 20; y++ {
|
||||
p := op.Push(ops)
|
||||
op.TransformOp{}.Offset(f32.Pt(float32(x*50+25), float32(y*50+25))).Add(ops)
|
||||
op.Offset(f32.Pt(float32(x*50+25), float32(y*50+25))).Add(ops)
|
||||
c.Add(ops)
|
||||
p.Pop()
|
||||
rad += math.Pi * 2 / 400
|
||||
@@ -262,7 +262,7 @@ func drawText(gtx layout.Context, th *material.Theme) chan op.CallOp {
|
||||
for x := 0; x < 40; x++ {
|
||||
txt.Text = textRows[x]
|
||||
p := op.Push(ops)
|
||||
op.TransformOp{}.Offset(f32.Pt(float32(0), float32(24*x))).Add(ops)
|
||||
op.Offset(f32.Pt(float32(0), float32(24*x))).Add(ops)
|
||||
gtx.Ops = ops
|
||||
txt.Layout(gtx)
|
||||
p.Pop()
|
||||
|
||||
@@ -31,7 +31,7 @@ func TestTransformMacro(t *testing.T) {
|
||||
paint.ColorOp{Color: colornames.Red}.Add(o)
|
||||
// Simulate a draw text call
|
||||
stack := op.Push(o)
|
||||
op.TransformOp{}.Offset(f32.Pt(0, 10)).Add(o)
|
||||
op.Offset(f32.Pt(0, 10)).Add(o)
|
||||
|
||||
// Actually create the text clip-path
|
||||
c.Add(o)
|
||||
@@ -43,11 +43,11 @@ func TestTransformMacro(t *testing.T) {
|
||||
|
||||
// Call each of them in a transform
|
||||
s1 := op.Push(o)
|
||||
op.TransformOp{}.Offset(f32.Pt(0, 0)).Add(o)
|
||||
op.Offset(f32.Pt(0, 0)).Add(o)
|
||||
c1.Add(o)
|
||||
s1.Pop()
|
||||
s2 := op.Push(o)
|
||||
op.TransformOp{}.Offset(f32.Pt(0, 0)).Add(o)
|
||||
op.Offset(f32.Pt(0, 0)).Add(o)
|
||||
c2.Add(o)
|
||||
s2.Pop()
|
||||
}, func(r result) {
|
||||
@@ -142,7 +142,7 @@ func TestReuseStencil(t *testing.T) {
|
||||
stack1.Pop()
|
||||
|
||||
stack2 := op.Push(ops)
|
||||
op.TransformOp{}.Offset(f32.Pt(0, 50)).Add(ops)
|
||||
op.Offset(f32.Pt(0, 50)).Add(ops)
|
||||
c2.Add(ops)
|
||||
stack2.Pop()
|
||||
}, func(r result) {
|
||||
@@ -159,7 +159,7 @@ func TestBuildOffscreen(t *testing.T) {
|
||||
txt := constSqCirc()
|
||||
draw := func(off float32, o *op.Ops) {
|
||||
s := op.Push(o)
|
||||
op.TransformOp{}.Offset(f32.Pt(0, off)).Add(o)
|
||||
op.Offset(f32.Pt(0, off)).Add(o)
|
||||
txt.Add(o)
|
||||
paint.PaintOp{Rect: f32.Rect(0, 0, 40, 40)}.Add(o)
|
||||
s.Pop()
|
||||
|
||||
Reference in New Issue
Block a user