1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 22:28:16 +01:00

add nz_voronoi2s

This commit is contained in:
Justin Lin 2020-03-29 17:00:55 +08:00
parent 4a26673b75
commit dcc8755eea
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,22 @@
use <experimental/nz_voronoi2s.scad>;
size = [100, 50];
dim = 5;
seed = 5;
points = [
for(y = [0:size[1] - 1])
for(x = [0:size[0] - 1])
[x, y]
];
noises = nz_voronoi2s(size, points, seed, dim);
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);
}

View File

@ -0,0 +1,11 @@
use <util/rand.scad>;
use <experimental/_impl/_nz_voronoi2_impl.scad>;
function nz_voronoi2s(size, points, seed, dim = 2) =
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_voronoi2(p, sd, dim, m, n)];