-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path08_gg_simple_path.go
More file actions
49 lines (40 loc) · 1.17 KB
/
08_gg_simple_path.go
File metadata and controls
49 lines (40 loc) · 1.17 KB
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
// Seriál "Programovací jazyk Go"
// https://www.root.cz/serialy/programovaci-jazyk-go/
//
// Šestnáctá část
// Programovací jazyk Go a grafika: další užitečné funkce poskytované knihovnou GG
// https://www.root.cz/clanky/programovaci-jazyk-go-a-grafika-dalsi-uzitecne-funkce-poskytovane-knihovnou-gg/
//
// Repositář:
// https://github.com/tisnik/go-root/
//
// Seznam demonstračních příkladů ze šestnácté části:
// https://github.com/tisnik/go-root/blob/master/article_16/README.md
//
// Demonstrační příklad číslo 8:
// Práce s cestou (path).
//
// Dokumentace ve stylu "literate programming":
// https://tisnik.github.io/go-root/article_16/08_gg_simple_path.html
package main
import "github.com/fogleman/gg"
func main() {
const width = 320
const height = 240
dc := gg.NewContext(width, height)
dc.DrawRectangle(0, 0, width, height)
dc.SetRGB(1.0, 1.0, 1.0)
dc.Fill()
dc.SetRGBA(0.0, 0.0, 0.0, 1)
dc.MoveTo(100, 200)
dc.LineTo(200, 200)
dc.LineTo(100, 100)
dc.LineTo(100, 200)
dc.LineTo(200, 100)
dc.LineTo(100, 100)
dc.LineTo(150, 50)
dc.LineTo(200, 100)
dc.LineTo(200, 200)
dc.Stroke()
dc.SavePNG("08.png")
}