'better' biome map (more of a color variation map than a biome map)

This commit is contained in:
Tangent 2019-07-26 22:06:17 -07:00
parent 16e78fabc6
commit 0a80e6c1f3
4 changed files with 57 additions and 18 deletions

BIN
1564201658.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
1564202842.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

View File

@ -1,4 +1,4 @@
size = 250
size = 600
debug = false
biomes = {
@ -23,11 +23,34 @@ biomes = {
}
biomes = {
red: { 1, 0, 0, h: 0.5, t: 0 }
green: { 0, 1, 0, h: 0, t: 1 }
blue: { 0, 0, 1, h: 1, t: 1 }
"hot desert": { 1, 1, 0, h: 0, t: 1 }
ice: { 0, 1, 1, h: 1, t: 0 }
-- green: { 0, 1, 0, h: 0.5, t: 0.5 }
rainforest: { 0, 0.5, 0, h: 0, t: 0 }
}
biomes = {
-- temporary: assume h is precipitation
"hot desert": { 1, 1, 0, h: 0, t: 1 } -- hot and no rain
snow: { 1, 1, 1, h: 1, t: 0 } -- high precip, no temp
rainforest: { 0, 0.5, 0, h: 1, t: 1 } -- hot and rainy
"frozen desert": { 0, 1, 1, h: 0, t: 0 } -- no rain, no temp
}
-- biomes = {
-- red: { 1, 0, 0, h: 0.5, t: 0 }
-- green: { 0, 1, 0, h: 0, t: 1 }
-- blue: { 0, 0, 1, h: 1, t: 1 }
-- -- black: { 0, 0, 0, h: 0.5, t: 0.5 }
-- -- white: { 1, 1, 1, h: 0.5, t: 0.5 }
-- greendark: { 0, 0.75, 0, h: 0.5, t: 0.5 }
-- }
-- biomes = {
-- red: { 1, 0, 0, h:0.5,t:0}
-- green:{0,1,0,h:0.5,t:1}
-- }
d2 = (A, B) ->
dx = A[1] - B[1]
dy = A[2] - B[2]
@ -44,18 +67,6 @@ merge = (A, B, d) ->
g = math.sqrt ((A[2]*c)^2 + (B[2]*d)^2) / (2 - f)
b = math.sqrt ((A[3]*c)^2 + (B[3]*d)^2) / (2 - f)
a = math.sqrt ((A[4]*c)^2 + (B[4]*d)^2) / (2 - f)
-- r = math.abs (A[1] + B[1]*d) / (2 - f)
-- g = math.abs (A[2] + B[2]*d) / (2 - f)
-- b = math.abs (A[3] + B[3]*d) / (2 - f)
-- a = math.abs (A[4] + B[4]*d) / (2 - f)
-- r = math.sqrt math.abs(A[1]^2 - B[1]^2)*d + A[1]^2
-- g = math.sqrt math.abs(A[2]^2 - B[2]^2)*d + A[2]^2
-- b = math.sqrt math.abs(A[3]^2 - B[3]^2)*d + A[3]^2
-- a = math.sqrt math.abs(A[4]^2 - B[4]^2)*d + A[4]^2
-- r = math.sqrt (A[1]^2 + B[1]^2) / 2
-- g = math.sqrt (A[2]^2 + B[2]^2) / 2
-- b = math.sqrt (A[3]^2 + B[3]^2) / 2
-- a = math.sqrt (A[4]^2 + B[4]^2) / 2
return { r, g, b, a }
average = (A, B) ->
@ -90,6 +101,34 @@ love.load = ->
love.window.setMode size, size
max_distance = math.sqrt d2({0, 0}, {1, 1})
final = {}
for h = 0, size
final[h] = {}
for t = 0, size
color = {0, 0, 0}
total_d = 0
for name, biome in pairs biomes
d = 1 - math.sqrt(d2({biome.h, biome.t},{h/size,t/size})) / max_distance
color[1] += (biome[1]*d)^2
color[2] += (biome[2]*d)^2
color[3] += (biome[3]*d)^2
total_d += d
-- print total_d
final[h][t] = {
-- math.sqrt color[1]^2 / total_d
math.sqrt((color[1]^2)) / total_d,
math.sqrt((color[2]^2)) / total_d,
math.sqrt((color[3]^2)) / total_d
}
if (h == 0 or h == size) and t == size
print color[1], color[2], color[3]
green = final[0][size]
blue = final[size][size]
print green[1], green[2], green[3]
print blue[1], blue[2], blue[3]
if true return
colors = {}
for name, biome in pairs biomes
colors[name] = {}
@ -133,12 +172,12 @@ love.load = ->
-- data.biome -- colors
love.draw = ->
for x = 1, size
for x = 0, size
-- green = size / x
-- yellow = 1 - green
-- yg = math.min green, yellow
-- love.graphics.setColor yellow, yg, 0, 1
for y = 1, size
for y = 0, size
love.graphics.setColor final[x][y]
love.graphics.points x, y