2025-03-25 23:55:13 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"image/color"
|
|
|
|
)
|
|
|
|
|
|
|
|
type colormode int
|
|
|
|
|
|
|
|
const (
|
|
|
|
cdefault colormode = iota
|
|
|
|
crandom
|
|
|
|
ctimed
|
|
|
|
crainbow
|
|
|
|
)
|
|
|
|
|
|
|
|
type outputmode int
|
|
|
|
|
|
|
|
const (
|
|
|
|
outputpng outputmode = iota
|
|
|
|
outputvideo
|
|
|
|
)
|
|
|
|
|
|
|
|
type settings struct {
|
2025-03-26 00:51:46 +03:00
|
|
|
X, Y int // image size
|
|
|
|
Dots int // dots to draw for single image
|
|
|
|
BG color.Color // background color
|
|
|
|
CM colormode // settings for colorFunc
|
|
|
|
OM outputmode // what to output
|
|
|
|
Fname string // filename for output
|
2025-03-25 23:55:13 +03:00
|
|
|
}
|
|
|
|
|
2025-03-26 00:51:46 +03:00
|
|
|
func parseSettings() *settings {
|
2025-03-25 23:55:13 +03:00
|
|
|
var (
|
2025-03-26 00:51:46 +03:00
|
|
|
x, y int
|
|
|
|
dots int
|
|
|
|
cmode int
|
|
|
|
output int
|
|
|
|
fname string
|
2025-03-25 23:55:13 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
flag.IntVar(&x, "x", 1920, "размер картинки по горизонтали")
|
|
|
|
flag.IntVar(&y, "y", 1080, "размер картинки по вертикали")
|
|
|
|
flag.IntVar(&dots, "d", 100000, "сколько точек рисовать")
|
|
|
|
flag.IntVar(&cmode, "color", 0, "color mode: 0 - default green, 1 - random, 2 - timed, 3 - rainbow")
|
2025-03-26 00:51:46 +03:00
|
|
|
flag.IntVar(&output, "o", 0, "режим вывода: 0 - изображение png, 1 - видео")
|
2025-03-25 23:55:13 +03:00
|
|
|
flag.StringVar(&fname, "out", "barnsley-fern.png", "полный путь файла для записи изображения")
|
|
|
|
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
s := &settings{
|
2025-03-26 00:51:46 +03:00
|
|
|
X: x,
|
|
|
|
Y: y,
|
|
|
|
Dots: dots,
|
|
|
|
BG: color.White,
|
|
|
|
CM: colormode(cmode),
|
|
|
|
OM: outputmode(output),
|
|
|
|
Fname: fname,
|
2025-03-25 23:55:13 +03:00
|
|
|
}
|
|
|
|
|
2025-03-26 00:51:46 +03:00
|
|
|
return s
|
2025-03-25 23:55:13 +03:00
|
|
|
}
|