MCPcopy
hub / github.com/fogleman/primitive / main

Function main

main.go:91–207  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89}
90
91func main() {
92 // parse and validate arguments
93 flag.Parse()
94 ok := true
95 if Input == "" {
96 ok = errorMessage("ERROR: input argument required")
97 }
98 if len(Outputs) == 0 {
99 ok = errorMessage("ERROR: output argument required")
100 }
101 if len(Configs) == 0 {
102 ok = errorMessage("ERROR: number argument required")
103 }
104 if len(Configs) == 1 {
105 Configs[0].Mode = Mode
106 Configs[0].Alpha = Alpha
107 Configs[0].Repeat = Repeat
108 }
109 for _, config := range Configs {
110 if config.Count < 1 {
111 ok = errorMessage("ERROR: number argument must be > 0")
112 }
113 }
114 if !ok {
115 fmt.Println("Usage: primitive [OPTIONS] -i input -o output -n count")
116 flag.PrintDefaults()
117 os.Exit(1)
118 }
119
120 // set log level
121 if V {
122 primitive.LogLevel = 1
123 }
124 if VV {
125 primitive.LogLevel = 2
126 }
127
128 // seed random number generator
129 rand.Seed(time.Now().UTC().UnixNano())
130
131 // determine worker count
132 if Workers < 1 {
133 Workers = runtime.NumCPU()
134 }
135
136 // read input image
137 primitive.Log(1, "reading %s\n", Input)
138 input, err := primitive.LoadImage(Input)
139 check(err)
140
141 // scale down input image if needed
142 size := uint(InputSize)
143 if size > 0 {
144 input = resize.Thumbnail(size, size, input, resize.Bilinear)
145 }
146
147 // determine background color
148 var bg primitive.Color

Callers

nothing calls this directly

Calls 6

StepMethod · 0.95
SVGMethod · 0.95
FramesMethod · 0.95
errorMessageFunction · 0.85
checkFunction · 0.85
ImageMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…