Skip to content

Instantly share code, notes, and snippets.

@rythmkraze
Created December 22, 2019 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rythmkraze/b88d4714c87e9303892f08984c135d24 to your computer and use it in GitHub Desktop.
Save rythmkraze/b88d4714c87e9303892f08984c135d24 to your computer and use it in GitHub Desktop.
package main
import (
"image/color"
"gioui.org/app"
"gioui.org/f32"
"gioui.org/io/system"
"gioui.org/op"
"gioui.org/op/clip"
"gioui.org/op/paint"
)
func main() {
go func() {
w := app.NewWindow()
ops := new(op.Ops)
for e := range w.Events() {
if e, ok := e.(system.FrameEvent); ok {
ops.Reset()
r := f32.Rectangle{
Max: f32.Point{X: 400, Y: 400},
}
p := &clip.Path{}
p.Begin(ops)
//<svg height="210" width="400">
// <path d="M150 0 L75 200 L225 200 Z" />
//</svg>
p.Move(f32.Point{X: 150, Y: 0})
p.Line(f32.Point{X: 75, Y: 200})
p.Line(f32.Point{X: 225, Y: 200})
p.Line(f32.Point{X: 150, Y: 0})
p.End().Add(ops)
paint.ColorOp{Color: color.RGBA{A: 0xff}}.Add(ops)
paint.PaintOp{Rect: r}.Add(ops)
e.Frame(ops)
}
}
}()
app.Main()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment