aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Byron <=>2015-07-20 23:23:56 +1000
committerDaniel Byron <=>2015-07-20 23:23:56 +1000
commit394a4db3d8572b0873abcc5fc9195c77fe2ae83b (patch)
treed9eac84fcd9c36e4a1d796a1d529ec4634a38acb
parentUpdated TODO (diff)
downloadschemer2-394a4db3d8572b0873abcc5fc9195c77fe2ae83b.tar.xz
schemer2-394a4db3d8572b0873abcc5fc9195c77fe2ae83b.zip
Fixed creating background colored objects behaviour and minor flag changes
-rw-r--r--image.go24
-rw-r--r--main.go24
2 files changed, 29 insertions, 19 deletions
diff --git a/image.go b/image.go
index 035ca81..35101e0 100644
--- a/image.go
+++ b/image.go
@@ -121,7 +121,7 @@ func imageFromColors(colors []color.Color, w int, h int) (image.Image, error) {
case "random":
return randomImage(colors, w, h), nil
case "circles":
- return Circles(colors, w, h, *circleSize, *circleSizeVariance, *circleOverlap, *circleDrawLargestToSmallest, *circleFilled, *circleBorderSize), nil
+ return Circles(colors, w, h, *circlesSize, *circlesSizeVariance, *circlesOverlap, *circlesDrawLargestToSmallest, *circlesFilled, *circlesBorderSize), nil
case "rays":
return Rays(colors, w, h, *raysSize, *raysSizeVariance, *raysDistributeEvenly, *raysCentered, *raysDrawLargestToSmallest), nil
case "stripes":
@@ -148,14 +148,17 @@ func Circles(colors []color.Color, w int, h int, size int, sizevar int, overlap
img := image.NewNRGBA(image.Rect(0, 0, w, h))
circles := make([]Circle, 0)
+ bg := colors[0]
for _, c := range colors {
+ // Do not create circle with background color
+ if c == bg {
+ continue
+ }
circle := Circle{c, rand.Intn(w), rand.Intn(h), randMinMax(size-sizevar, size+sizevar)}
circles = append(circles, circle)
}
- bg := colors[0]
-
if large2small {
sort.Sort(sort.Reverse(circleBySize(circles)))
}
@@ -207,7 +210,13 @@ func Rays(colors []color.Color, w int, h int, size int, sizevar int, evendist bo
xpos := w / 2
ypos := h / 2
+ bg := colors[0]
+
for _, c := range colors {
+ // Do not create ray with background color
+ if c == bg {
+ continue
+ }
var ray Ray
if !centered {
xpos = rand.Intn(w)
@@ -228,8 +237,6 @@ func Rays(colors []color.Color, w int, h int, size int, sizevar int, evendist bo
sort.Sort(sort.Reverse(rayBySize(rays)))
}
- bg := colors[0]
-
for x := 0; x < w; x++ {
for y := 0; y < h; y++ {
img.Set(x, y, bg)
@@ -268,8 +275,13 @@ func Lines(colors []color.Color, w int, h int, size int, sizevar int, horizontal
spacing := spacingsize
lines := make([]Line, 0)
+ bg := colors[0]
for _, c := range colors {
+ // Do not create line with background color
+ if c == bg {
+ continue
+ }
line := Line{c, currentposition, randMinMax(size-sizevar, size+sizevar)}
lines = append(lines, line)
if !equalspacing {
@@ -278,8 +290,6 @@ func Lines(colors []color.Color, w int, h int, size int, sizevar int, horizontal
currentposition += line.size + spacing
}
- bg := colors[0]
-
for x := 0; x < w; x++ {
for y := 0; y < h; y++ {
img.Set(x, y, bg)
diff --git a/main.go b/main.go
index 4e1971d..a3abd4f 100644
--- a/main.go
+++ b/main.go
@@ -30,12 +30,12 @@ var (
imageOutType *string // Eg, "random", "circles", "stripes", etc...
// Circles image output options
- circleSize *int
- circleSizeVariance *int
- circleOverlap *bool
- circleDrawLargestToSmallest *bool
- circleFilled *bool
- circleBorderSize *int
+ circlesSize *int
+ circlesSizeVariance *int
+ circlesOverlap *bool
+ circlesDrawLargestToSmallest *bool
+ circlesFilled *bool
+ circlesBorderSize *int
// Ray image output options
raysSize *int
@@ -112,12 +112,12 @@ func main() {
imageOutType = flag.String("imageOutType", "random", imageOutTypeDesc)
// Circles image output options
- circleSize = flag.Int("circleSize", 100, "Size of circles in output image")
- circleSizeVariance = flag.Int("circleSizeVariance", 50, "Maximum variance in circle size")
- circleOverlap = flag.Bool("circleOverlap", true, "Allow circles to overlap !!! Unimplemented !!!")
- circleDrawLargestToSmallest = flag.Bool("circleLargeToSmall", true, "Order circles z-index by size (smaller circles are drawn in front of larger circles)")
- circleFilled = flag.Bool("circleFilled", false, "Fill circles")
- circleBorderSize = flag.Int("circleBorderSize", 10, "Border of circles when unfilled")
+ circlesSize = flag.Int("circlesSize", 100, "Size of circles in output image")
+ circlesSizeVariance = flag.Int("circlesSizeVariance", 50, "Maximum variance in circle size")
+ circlesOverlap = flag.Bool("circlesOverlap", true, "Allow circles to overlap !!! Unimplemented !!!")
+ circlesDrawLargestToSmallest = flag.Bool("circlesLargeToSmall", true, "Order circles z-index by size (smaller circles are drawn in front of larger circles)")
+ circlesFilled = flag.Bool("circlesFilled", false, "Fill circles")
+ circlesBorderSize = flag.Int("circlesBorderSize", 10, "Border of circles when unfilled")
// Ray image output options
raysSize = flag.Int("raysSize", 16, "Size of rays in output image")