Skip to content

Commit

Permalink
updated gio version
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Naur <mail@eliasnaur.com>
  • Loading branch information
eliasnaur committed Nov 9, 2019
1 parent a0b590a commit b9eb248
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
26 changes: 7 additions & 19 deletions animatedclipping.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"gioui.org/f32"
"gioui.org/io/system"
"gioui.org/op"
"gioui.org/op/clip"
"gioui.org/op/paint"
)

Expand All @@ -32,7 +33,12 @@ func main() {
// Color
paint.ColorOp{Color: color.RGBA{A: 0xff, G: 0xcc}}.Add(ops) // HLdraw
// Clip corners
roundRect(ops, 500, 500, radius, radius, radius, radius) // HLdraw
clip.RoundRect(ops, // HLdraw
f32.Rectangle{ // HLdraw
Max: f32.Point{X: 500, Y: 500}, // HLdraw
}, // HLdraw
radius, radius, radius, radius, // HLdraw
).Add(ops) // HLdraw
// Draw
paint.PaintOp{Rect: square}.Add(ops) // HLdraw
// Animate
Expand All @@ -47,24 +53,6 @@ func main() {
app.Main()
}

// START RR OMIT
// https://pomax.github.io/bezierinfo/#circles_cubic.
func roundRect(ops *op.Ops, width, height, se, sw, nw, ne float32) {
w, h := float32(width), float32(height)
const c = 0.55228475 // 4*(sqrt(2)-1)/3
var b paint.Path
b.Begin(ops)
b.Move(f32.Point{X: w, Y: h - se})
b.Cube(f32.Point{X: 0, Y: se * c}, f32.Point{X: -se + se*c, Y: se}, f32.Point{X: -se, Y: se})
b.Line(f32.Point{X: sw - w + se, Y: 0})
b.Cube(f32.Point{X: -sw * c, Y: 0}, f32.Point{X: -sw, Y: -sw + sw*c}, f32.Point{X: -sw, Y: -sw})
b.Line(f32.Point{X: 0, Y: nw - h + sw})
b.Cube(f32.Point{X: 0, Y: -nw * c}, f32.Point{X: nw - nw*c, Y: -nw}, f32.Point{X: nw, Y: -nw})
b.Line(f32.Point{X: w - ne - nw, Y: 0})
b.Cube(f32.Point{X: ne * c, Y: 0}, f32.Point{X: ne, Y: ne - ne*c}, f32.Point{X: ne, Y: ne})
b.End().Add(ops)
}

// END RR OMIT

var start = time.Now()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module gophercon2019

go 1.13

require gioui.org v0.0.0-20191107200801-f1d971268eb1
require gioui.org v0.0.0-20191109184610-d8c9cb426c41
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
gioui.org v0.0.0-20191107200801-f1d971268eb1 h1:Xp6py0emaiFCoiiz6tDXjErHnFMxtVcCnbh78KBm+6k=
gioui.org v0.0.0-20191107200801-f1d971268eb1/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY=
gioui.org v0.0.0-20191109184610-d8c9cb426c41 h1:MC7OzV8nE8N1fBl3MgZLe8xquNkr+uezK0+1cnxrJFc=
gioui.org v0.0.0-20191109184610-d8c9cb426c41/go.mod h1:KqFFi2Dq5gYA3FJ0sDOt8OBXoMsuxMtE8v2f0JExXAY=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down

0 comments on commit b9eb248

Please sign in to comment.