experimenting
This commit is contained in:
parent
3fd7bbbc71
commit
16e78fabc6
BIN
1564198479.png
Normal file
BIN
1564198479.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
1564198548.png
Normal file
BIN
1564198548.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
BIN
1564199903.png
Normal file
BIN
1564199903.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
@ -1,4 +1,4 @@
|
||||
size = 500
|
||||
size = 250
|
||||
debug = false
|
||||
|
||||
biomes = {
|
||||
@ -22,6 +22,11 @@ biomes = {
|
||||
-- "dark green": { 0, 0.2, 0, 1, h: 0.5, p: 1, t: 0.5 }
|
||||
}
|
||||
|
||||
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 }
|
||||
}
|
||||
|
||||
d2 = (A, B) ->
|
||||
dx = A[1] - B[1]
|
||||
@ -53,6 +58,13 @@ merge = (A, B, d) ->
|
||||
-- a = math.sqrt (A[4]^2 + B[4]^2) / 2
|
||||
return { r, g, b, a }
|
||||
|
||||
average = (A, B) ->
|
||||
return {
|
||||
math.sqrt((A[1]^2 + B[1]^2)/2),
|
||||
math.sqrt((A[2]^2 + B[2]^2)/2),
|
||||
math.sqrt((A[3]^2 + B[3]^2)/2)
|
||||
}
|
||||
|
||||
love.load = ->
|
||||
love.window.setMode size, size
|
||||
|
||||
@ -73,6 +85,53 @@ love.load = ->
|
||||
d = distances[1][1] / distances[2][1] --/ 2
|
||||
colors[h][t] = merge(distances[1][3], distances[2][3], d)
|
||||
|
||||
local final
|
||||
love.load = ->
|
||||
love.window.setMode size, size
|
||||
|
||||
max_distance = math.sqrt d2({0, 0}, {1, 1})
|
||||
colors = {}
|
||||
for name, biome in pairs biomes
|
||||
colors[name] = {}
|
||||
map = colors[name]
|
||||
for h = 0, size
|
||||
map[h] = {}
|
||||
for t = 0, size
|
||||
d = math.sqrt d2({biome.h, biome.t}, {h/size, t/size})
|
||||
range = 1 - d / max_distance
|
||||
map[h][t] = {
|
||||
biome[1] * range,
|
||||
biome[2] * range,
|
||||
biome[3] * range
|
||||
}
|
||||
-- final = colors.blue --{}
|
||||
final = {}
|
||||
for h = 0, size
|
||||
final[h] = {}
|
||||
for t = 0, size
|
||||
v = { 0, 0, 0 }
|
||||
for name, color in pairs colors
|
||||
color = color[h][t]
|
||||
v[1] += color[1]
|
||||
v[2] += color[2]
|
||||
v[3] += color[3]
|
||||
final[h][t] = v
|
||||
|
||||
-- love.load = ->
|
||||
-- love.window.setMode size, size
|
||||
-- for h = 0, size
|
||||
-- for t = 0, size
|
||||
-- distances = {}
|
||||
-- for name, biome in pairs biomes
|
||||
-- table.insert distances, {
|
||||
-- d2: d2({biome.h, biome.t}, {h/size, t/size})
|
||||
-- :name, :biome
|
||||
-- }
|
||||
-- table.sort distances, (A, B) -> return A.d2 < B.d2
|
||||
-- for data in *distances
|
||||
-- -- somehow combine w one behind it
|
||||
-- data.biome -- colors
|
||||
|
||||
love.draw = ->
|
||||
for x = 1, size
|
||||
-- green = size / x
|
||||
@ -80,13 +139,13 @@ love.draw = ->
|
||||
-- yg = math.min green, yellow
|
||||
-- love.graphics.setColor yellow, yg, 0, 1
|
||||
for y = 1, size
|
||||
love.graphics.setColor colors[x][y]
|
||||
love.graphics.setColor final[x][y]
|
||||
love.graphics.points x, y
|
||||
|
||||
if debug
|
||||
love.graphics.setColor 1, 0, 0, 1
|
||||
for _, bitch in pairs biomes
|
||||
love.graphics.circle "line", bitch.h * size, bitch.t * size, 2
|
||||
for _, biome in pairs biomes
|
||||
love.graphics.circle "line", biome.h * size, biome.t * size, 2
|
||||
|
||||
love.keypressed = (key) ->
|
||||
love.event.quit! if key == "escape"
|
||||
|
Loading…
Reference in New Issue
Block a user