Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"math"
"github.com/faiface/pixel"
"github.com/faiface/pixel/imdraw"
"github.com/faiface/pixel/pixelgl"
"golang.org/x/image/colornames"
)
func run() {
cfg := pixelgl.WindowConfig{
Title: "Pixel Rocks!",
Bounds: pixel.R(0, 0, 1024, 768),
VSync: true,
}
win, err := pixelgl.NewWindow(cfg)
if err != nil {
panic(err)
}
imd := imdraw.New(nil)
imd.Color(colornames.Blueviolet)
imd.EndShape(imdraw.RoundEndShape)
imd.Push(pixel.V(100, 100), pixel.V(700, 100))
imd.EndShape(imdraw.SharpEndShape)
imd.Push(pixel.V(100, 500), pixel.V(700, 500))
imd.Line(30)
imd.Color(colornames.Limegreen)
imd.Push(pixel.V(500, 500))
imd.Circle(300, 50)
imd.Color(colornames.Navy)
imd.Push(pixel.V(200, 500), pixel.V(800, 500))
imd.Ellipse(pixel.V(120, 80), 0)
imd.Color(colornames.Red)
imd.EndShape(imdraw.RoundEndShape)
imd.Push(pixel.V(500, 350))
imd.CircleArc(150, -math.Pi, 0, 30)
for !win.Closed() {
win.Clear(colornames.Aliceblue)
imd.Draw(win)
win.Update()
}
}
func main() {
pixelgl.Run(run)
}