-
Notifications
You must be signed in to change notification settings - Fork 1
/
package_usage_sample.go
executable file
·94 lines (85 loc) · 2.2 KB
/
package_usage_sample.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//packages usage samples
package main
import (
"fmt"
"github.com/Geoferry/Godar/models"
"github.com/Geoferry/Godar/utils"
"image"
"image/color"
"image/png"
"os"
"sync"
)
func main() {
var wg sync.WaitGroup
path := ""
wg.Add(4)
/******* package Utils usage sample -- DrawLine *******/
go func() {
path, _ = utils.NewImagePath()
f1, err := os.Create(path)
if err != nil {
fmt.Println(err)
}
defer f1.Close()
r1 := image.NewRGBA(utils.SetSize())
utils.DrawLine(20, 150, 120, 250, 0, color.RGBA{0, 0, 0, 255}, r1)
png.Encode(f1, r1)
fmt.Println("DrawLine Sample finished")
wg.Done()
}()
/******* package Utils usage sample -- DrawCircle *******/
go func() {
path, _ = utils.NewImagePath()
f2, err := os.Create(path)
if err != nil {
fmt.Println(err)
}
defer f2.Close()
r2 := image.NewRGBA(utils.SetSize())
utils.DrawCircle(128, 128, 40, 3, color.RGBA{0, 0, 0, 255}, r2)
png.Encode(f2, r2)
fmt.Println("DrawCircle Sample finished")
wg.Done()
}()
/******* package Models usage sample -- Ngon *******/
go func() {
path, _ = utils.NewImagePath()
f3, err := os.Create(path)
if err != nil {
fmt.Println(err)
}
defer f3.Close()
r3 := image.NewRGBA(utils.SetSize(2560, 1920))
p := models.Ngon{}
p.New(6, r3)
p.FillLayer(1, r3, color.RGBA{80, 180, 240, 255})
p.FillLayer(2, r3, color.RGBA{40, 120, 160, 255})
p.FillLayer(3, r3, color.RGBA{20, 60, 80, 255})
p.DrawNgonLine(2, r3, color.RGBA{0, 0, 0, 255})
png.Encode(f3, r3)
fmt.Println("N regular polygon radar chart sample finished")
wg.Done()
}()
/******* package Models usage sample -- Circle *******/
go func() {
path, _ = utils.NewImagePath()
f4, err := os.Create(path)
if err != nil {
fmt.Println(err)
}
defer f4.Close()
r4 := image.NewRGBA(utils.SetSize(2560, 1920))
cir := models.Circle{}
cir.New(5, r4)
cir.FillLayer(1, r4, color.RGBA{160, 150, 190, 255})
cir.FillLayer(2, r4, color.RGBA{140, 110, 150, 255})
cir.FillLayer(3, r4, color.RGBA{120, 70, 230, 255})
//cir.FillLayer(4, r4, color.RGBA{60, 35, 115, 255})
cir.DrawCurve(3, r4, color.RGBA{0, 0, 0, 255})
png.Encode(f4, r4)
fmt.Println("Circular radar chart sample finished")
wg.Done()
}()
wg.Wait()
}