annotate old_tests/test_noise.nim @ 1319:43db6f5abb61

add: more vector utils
author sam <sam@basx.dev>
date Tue, 13 Aug 2024 15:28:56 +0700
parents 6360c8d17ce0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
370
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
1 import semicongine
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
2
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
3 const w = 500
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
4 const h = 500
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
5
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
6 var o = "P2\n" & $ w & " " & $ h & "\n255\n"
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
7
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
8 for y in 0 ..< h:
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
9 for x in 0 ..< w:
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
10 let v = (
1139
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 1136
diff changeset
11 Perlin(NewVec2f(float(x) * 0.01, float(y) * 0.01)) * 0.7 +
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 1136
diff changeset
12 Perlin(NewVec2f(float(x) * 0.05, float(y) * 0.05)) * 0.25 +
114f395b9144 did: finish refactoring and updated all tests accordingly
sam <sam@basx.dev>
parents: 1136
diff changeset
13 Perlin(NewVec2f(float(x) * 0.2, float(y) * 0.2)) * 0.05
370
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
14 )
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
15 o = o & $(int((v * 0.5 + 0.5) * 255)) & " "
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
16 o = o & "\n"
fad6490fb728 add: missing material module, some functions for noise
Sam <sam@basx.dev>
parents:
diff changeset
17 echo o