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

add nz_voronoi3s

This commit is contained in:
Justin Lin 2020-03-29 20:11:05 +08:00
parent dff7db68ac
commit d5fce20b72
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,22 @@
use <experimental/nz_voronoi3s.scad>;
size = [20, 20, 20];
dim = 2;
seed = 5;
points = [
for(z = [0:size[2] - 1])
for(y = [0:size[1] - 1])
for(x = [0:size[0] - 1])
[x, y, z]
];
noises = nz_voronoi3s(size, points, seed, dim);
max_dist = max(noises);
for(i = [0:len(noises) - 1]) {
c = noises[i] / max_dist * 2;
color([c > 1 ? 1 : c , 0, 0])
translate(points[i])
square(1);
}

View File

@ -0,0 +1,12 @@
use <util/rand.scad>;
use <experimental/_impl/_nz_voronoi3_impl.scad>;
function nz_voronoi3s(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,
o = size[2] / dim
)
[for(p = points) _nz_voronoi3(p, sd, dim, m, n, o)];