Skip to content

Commit

Permalink
added variance (waving) property. moved to v0.3-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
paulwrubel committed Mar 24, 2018
1 parent 03551cf commit 0888ba1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 30 deletions.
35 changes: 27 additions & 8 deletions src/main/scala/me/paul/artgenerators/Generator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ object Generator {

})

var count = 0
var round = 0
var pixelCount = Parameters.SeedCount

// while image is not filled
Expand All @@ -152,6 +152,25 @@ object Generator {
p => {
var completed = true

def getSpreadChance(chance: Double, delta: Double) = {
if (delta >= 0) {
val x = (chance + (delta * round)) % 2.0
if (x >= 1.0) {
1 - ((chance + (round * delta)) % 1.0)
} else {
(chance + (round * delta)) % 1.0
}
} else {
val x = (chance + (-delta * round)) % 2.0
//println("result: " + x)
if (x < 1.0) {
1 - ((chance + (round * -delta)) % 1.0)
} else {
(chance + (round * -delta)) % 1.0
}
}
}

def handlePixel(newPixel: (Int, Int), sc: Double): Unit = {
if (!read.getColor(newPixel._1, newPixel._2).isOpaque) {
if (randomUpTo(1) < sc) {
Expand All @@ -164,10 +183,10 @@ object Generator {
}
}

if (p._2 != 0) handlePixel((p._1 , p._2 - 1), Parameters.NorthSpreadChance)
if (p._1 != Parameters.Width - 1) handlePixel((p._1 + 1, p._2 ), Parameters.EastSpreadChance)
if (p._2 != Parameters.Height - 1) handlePixel((p._1 , p._2 + 1), Parameters.SouthSpreadChance)
if (p._1 != 0) handlePixel((p._1 - 1, p._2 ), Parameters.WestSpreadChance)
if (p._2 != 0) handlePixel((p._1 , p._2 - 1), getSpreadChance(Parameters.NorthSpreadChance, Parameters.NorthSpreadChanceDelta))
if (p._1 != Parameters.Width - 1) handlePixel((p._1 + 1, p._2 ), getSpreadChance(Parameters.EastSpreadChance, Parameters.EastSpreadChanceDelta))
if (p._2 != Parameters.Height - 1) handlePixel((p._1 , p._2 + 1), getSpreadChance(Parameters.SouthSpreadChance, Parameters.SouthSpreadChanceDelta))
if (p._1 != 0) handlePixel((p._1 - 1, p._2 ), getSpreadChance(Parameters.WestSpreadChance, Parameters.WestSpreadChanceDelta))

if (completed) {
progress -= p
Expand All @@ -177,13 +196,13 @@ object Generator {

val time2 = System.nanoTime

if (Parameters.Debug && count % 10 == 0) {
println(f"[Image #$imageNum%4d] Round $count%6d: " +
if (Parameters.Debug && round % 10 == 0) {
println(f"[Image #$imageNum%4d] Round $round%6d: " +
f"Time: ${time2 - time1}%,15dns, " +
f"Pixels Completed: $pixelCount%,13d / ${Parameters.Width * Parameters.Height}%,13d " +
f"[${100 * pixelCount.asInstanceOf[Double] / (Parameters.Width * Parameters.Height)}%6.2f%%]")
}
count += 1
round += 1

}
}
Expand Down
44 changes: 22 additions & 22 deletions src/main/scala/me/paul/artgenerators/Parameters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@ package me.paul.artgenerators

object Parameters {

val Debug = true
val Version = "v0.2-alpha"
val Debug: Boolean = true
val Version: String = "v0.3-alpha"

val ImageCount = 1
val OpenFile = true
val ImageCount: Int = 1
val OpenFile: Boolean = true

// HD : 1280 x 720
// Full HD : 1920 × 1080
// True 4K : 4096 × 2160
// True 8K : 8192 × 4320
// Max Possible (32K) : 30720 x 17280
val Width = 1920
val Height = 1080
val Width: Int = 1920
val Height: Int = 1080

val Filename = f"$Version-${Width}x$Height"
val Filepath = f"./out/images/$Version/${Width}x$Height/"
val FileFormat = "png"
val Filename: String = f"$Version-${Width}x$Height"
val Filepath: String = f"./out/images/$Version/${Width}x$Height/"
val FileFormat: String = "png"

val SeedCount = 5
val SeedCount: Int = 1

val HueVariation = 1
val SaturationVariation = 0.02
val BrightnessVariation = 0.02
val HueVariation: Double = 5
val SaturationVariation: Double = 0.02
val BrightnessVariation: Double = 0.02

val HueBounds: (Double, Double) = (0, 360)
val HueBounds: (Double, Double) = (90, 30)
val SaturationBounds: (Double, Double) = (0.5, 1)
val BrightnessBounds: (Double, Double) = (0.5, 1)

val NorthSpreadChance = 0.5
val EastSpreadChance = 0.5
val SouthSpreadChance = 0.5
val WestSpreadChance = 0.5
val NorthSpreadChance: Double = 0.25
val EastSpreadChance: Double = 0.75
val SouthSpreadChance: Double = 0.25
val WestSpreadChance: Double = 0.75

// unused for now
val NorthSpreadChanceDelta = 0.001
val EastSpreadChanceDelta = 0.001
val SouthSpreadChanceDelta = 0.001
val WestSpreadChanceDelta = 0.001
val NorthSpreadChanceDelta: Double = -0.01
val EastSpreadChanceDelta: Double = 0.01
val SouthSpreadChanceDelta: Double = -0.01
val WestSpreadChanceDelta: Double = 0.01

}

0 comments on commit 0888ba1

Please sign in to comment.