init trying to combine programmatically
This commit is contained in:
commit
a4ad373b79
69
src/main.moon
Normal file
69
src/main.moon
Normal file
@ -0,0 +1,69 @@
|
||||
biomes = {
|
||||
"frozen desert": { 1/3, 0.75, 0.76, 1, h: 0.5, p: 0.12, t: 0 }
|
||||
swamp: { 65/255, 104/255, 37/255, 1, h: 0.1, p: 1, t: 0.8 }
|
||||
-- savanna: { }
|
||||
-- shrubland: { }
|
||||
"broadleaf forest": { 0.2, 1, 0.2, 1, h: 0.6, p: 0.38, t: 0.4 }
|
||||
"evergreen forest": { 0, 0.75, 0, 1, h: 0.75, p: 0.46, t: 0.25 }
|
||||
"sandy desert": { 1, 1, 0.2, h: 0.45, p: 0, t: 0.5 }
|
||||
"baked desert": { 1, 0.75, 0.2, h: 0.5, p: 0, t: 1 }
|
||||
tundra: { 0, 1/3, 2/3, 1, h: 0.5, p: 0, t: 0 }
|
||||
-- tiaga: { }
|
||||
snow: { 0.9, 0.9, 0.9, 1, h: 0.8, p: 1, t: 0.05 }
|
||||
ice: { 0, 0.95, 0.95, 1, h: 1, p: 0.9, t: 0 }
|
||||
rainforest: { 0, 1, 0, 1, h: 0.4, p: 1, t: 1 }
|
||||
grassland: { 1/3, 1, 0, 1, h: 0.52, p: 0.18, t: 0.5 }
|
||||
|
||||
-- "bright green": { 0.2, 1, 0.2, 1, h: 0.5, p: 0, t: 0 }
|
||||
-- green: { 0, 1, 0, 1, h: 0.5, p: 0, t: 1 }
|
||||
-- "dark green": { 0, 0.2, 0, 1, h: 0.5, p: 1, t: 0.5 }
|
||||
}
|
||||
|
||||
colors = {}
|
||||
|
||||
d2 = (A, B) ->
|
||||
dx = A[1] - B[1]
|
||||
dy = A[2] - B[2]
|
||||
return dx * dx + dy * dy
|
||||
|
||||
size = 500
|
||||
|
||||
for h = 1, size
|
||||
colors[h] = {}
|
||||
for t = 1, size
|
||||
distances = {}
|
||||
for name, biome in pairs biomes
|
||||
table.insert distances, { d2({biome.h, biome.t}, {h/size, t/size}), name, biome }
|
||||
table.sort distances, (A, B) -> return A[1] < B[1]
|
||||
merge = (A, B, f) ->
|
||||
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] or 1)^2 + (B[4] or 1)^2) / 2
|
||||
return { r, g, b, a }
|
||||
merge2 = (A, B, f) ->
|
||||
r = math.sqrt (A[1]^2 + (B[1] * f)^2) / 2
|
||||
g = math.sqrt (A[2]^2 + (B[2] * f)^2) / 2
|
||||
b = math.sqrt (A[3]^2 + (B[3] * f)^2) / 2
|
||||
a = math.sqrt ((A[4] or 1)^2 + ((B[4] or 1) * f)^2) / 2
|
||||
return { r, g, b, a }
|
||||
merge3 = (A, B, f) ->
|
||||
r = math.sqrt (A[1]^2 + B[1]^2 / f) / 2
|
||||
g = math.sqrt (A[2]^2 + B[2]^2 / f) / 2
|
||||
b = math.sqrt (A[3]^2 + B[3]^2 / f) / 2
|
||||
a = math.sqrt ((A[4] or 1)^2 + (B[4] or 1)^2 / f) / 2
|
||||
return { r, g, b, a }
|
||||
-- colors[h][t] = distances[1][3]
|
||||
colors[h][t] = merge3 distances[1][3], distances[2][3], 1 / (distances[2][1] - distances[1][1])
|
||||
|
||||
love.draw = ->
|
||||
for x = 1, size
|
||||
for y = 1, size
|
||||
love.graphics.setColor colors[x][y]
|
||||
love.graphics.points x, y
|
||||
|
||||
love.graphics.setColor 1, 0, 0, 1
|
||||
for _, bitch in pairs biomes
|
||||
love.graphics.circle "line", bitch.h * size, bitch.t * size, 2
|
||||
|
||||
love.keypressed = (key) -> love.event.quit! if key == "escape"
|
Loading…
Reference in New Issue
Block a user