mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-17 20:11:50 +02:00
add nz_worley2s
This commit is contained in:
23
src/experimental/demo/nz_worley2s_demo.scad
Normal file
23
src/experimental/demo/nz_worley2s_demo.scad
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
use <experimental/nz_worley2s.scad>;
|
||||||
|
|
||||||
|
size = [100, 50];
|
||||||
|
dim = 5;
|
||||||
|
dist = "euclidean"; // [euclidean, manhattan, chebyshev]
|
||||||
|
seed = 5;
|
||||||
|
|
||||||
|
points = [
|
||||||
|
for(y = [0:size[1] - 1])
|
||||||
|
for(x = [0:size[0] - 1])
|
||||||
|
[x, y]
|
||||||
|
];
|
||||||
|
|
||||||
|
noises = nz_worley2s(size, points, seed, dim, dist);
|
||||||
|
|
||||||
|
max_dist = max(noises);
|
||||||
|
for(i = [0:len(noises) - 1]) {
|
||||||
|
c = noises[i] / max_dist;
|
||||||
|
color([c, c, c])
|
||||||
|
linear_extrude(c * max_dist)
|
||||||
|
translate(points[i])
|
||||||
|
square(1);
|
||||||
|
}
|
11
src/experimental/nz_worley2s.scad
Normal file
11
src/experimental/nz_worley2s.scad
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
use <util/rand.scad>;
|
||||||
|
use <experimental/_impl/_nz_worley2_comm.scad>;
|
||||||
|
|
||||||
|
function nz_worley2s(size, points, seed, dim = 3, dist = "euclidean") =
|
||||||
|
let(
|
||||||
|
sd = 6 + (is_undef(seed) ? floor(rand(0, 256)) : seed % 256),
|
||||||
|
// m*n pixels per grid
|
||||||
|
m = size[0] / dim,
|
||||||
|
n = size[1] / dim
|
||||||
|
)
|
||||||
|
[for(p = points) _nz_worley2(p, sd, dim, m, n, dist)];
|
Reference in New Issue
Block a user