-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path19_gg_line_width.go
More file actions
47 lines (37 loc) · 1.14 KB
/
19_gg_line_width.go
File metadata and controls
47 lines (37 loc) · 1.14 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
// Seriál "Programovací jazyk Go"
// https://www.root.cz/serialy/programovaci-jazyk-go/
//
// Patnáctá část
// Programovací jazyk Go a grafika: tvorba animovaných GIFů, grafická knihovna GG
// https://www.root.cz/clanky/programovaci-jazyk-go-a-grafika-tvorba-animovanych-gifu-graficka-knihovna-gg/
//
// Repositář:
// https://github.com/tisnik/go-root/
//
// Seznam demonstračních příkladů z patnácté části:
// https://github.com/tisnik/go-root/blob/master/article_15/README.md
//
// Demonstrační příklad číslo 19:
// Specifikace šířky vykreslovaných cest
//
// Dokumentace ve stylu "literate programming":
// https://tisnik.github.io/go-root/article_15/19_gg_line_width.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)
for i := 0; i < 256; i += 16 {
width := float64(i) / 20
dc.SetLineWidth(width)
x := float64(i + 32)
dc.DrawLine(x, 20, x, height-20)
dc.Stroke()
}
dc.SavePNG("19.png")
}