Mercurial > games > semicongine
diff tests/test_noise.nim @ 831:902735626b66
add: missing material module, some functions for noise
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 22 Nov 2023 23:23:40 +0700 |
parents | |
children | 71315636ba82 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_noise.nim Wed Nov 22 23:23:40 2023 +0700 @@ -0,0 +1,17 @@ +import semicongine + +const w = 500 +const h = 500 + +var o = "P2\n" & $ w & " " & $ h & "\n255\n" + +for y in 0 ..< h: + for x in 0 ..< w: + let v = ( + perlin(newVec2f(float(x) * 0.01, float(y) * 0.01)) * 0.7 + + perlin(newVec2f(float(x) * 0.05, float(y) * 0.05)) * 0.25 + + perlin(newVec2f(float(x) * 0.2, float(y) * 0.2)) * 0.05 + ) + o = o & $(int((v * 0.5 + 0.5) * 255)) & " " + o = o & "\n" +echo o