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:
parent
4a26673b75
commit
dcc8755eea
22
src/experimental/demo/nz_voronoi2s_demo.scad
Normal file
22
src/experimental/demo/nz_voronoi2s_demo.scad
Normal 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);
|
||||
}
|
11
src/experimental/nz_voronoi2s.scad
Normal file
11
src/experimental/nz_voronoi2s.scad
Normal 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)];
|
Loading…
x
Reference in New Issue
Block a user