-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path17_gg_filled_background.go
43 lines (35 loc) · 1.11 KB
/
17_gg_filled_background.go
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
// 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 17:
// Vyplnění pozadí konstantní barvou
//
// Dokumentace ve stylu "literate programming":
// https://tisnik.github.io/go-root/article_15/17_gg_filled_background.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.DrawLine(10, 10, width-10, height-10)
dc.SetRGB(0.2, 0.0, 0.8)
dc.Stroke()
dc.DrawLine(10, height-10, width-10, 10)
dc.SetRGB(0.8, 0.0, 0.2)
dc.Stroke()
dc.SavePNG("17.png")
}