-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
79 lines (65 loc) · 1.27 KB
/
main.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
package main
import (
"flag"
"fmt"
"image"
"os"
"strconv"
"github.com/chinanf-boy/primitive-explain/examples"
)
var (
Configs shapeConfigArray
Alpha int
Mode int
Repeat int
)
type shapeConfig struct {
Count int
Mode int
Alpha int
Repeat int
}
type shapeConfigArray []shapeConfig
func (i *shapeConfigArray) String() string {
return ""
}
func (i *shapeConfigArray) Set(value string) error {
fmt.Println("flag -n ", value)
fmt.Println("Set running")
n, _ := strconv.ParseInt(value, 0, 0)
*i = append(*i, shapeConfig{int(n), Mode, Alpha, Repeat})
return nil
}
func loadImage(path string) (image.Image, error) {
file, err := os.Open(path)
if err != nil {
return nil, err
}
defer file.Close()
im, _, err := image.Decode(file)
return im, err
}
func init() {
flag.Var(&Configs, "n", "number of primitives")
Mode = 1
Alpha = 1
Repeat = 1
}
func main() {
flag.Parse()
exampleIndex := flag.Args()
if exampleIndex[0] == "gg" {
examples.UseGG()
fmt.Println("examples gg create new png {out.png}")
os.Exit(0)
}
if exampleIndex[0] == "img2rgba" {
input, _ := loadImage("lenna.png")
rgbas := examples.ImageToRGBA(input)
fmt.Println("so many RGBA", rgbas)
os.Exit(0)
}
for _, config := range Configs {
fmt.Println("new config", config)
}
}