mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-17 14:18:13 +01:00
refactor
This commit is contained in:
parent
582d7642eb
commit
5da7a66fac
@ -16,5 +16,25 @@ function _nz_worley2(p, seed, grid_w, dist) =
|
||||
fcord = [floor(p.x / grid_w), floor(p.y / grid_w)],
|
||||
nbrs = _neighbors(fcord, seed, grid_w)
|
||||
)
|
||||
dist == "euclidean" ? _nz_worley_euclidean(p, nbrs) :
|
||||
dist == "manhattan" ? _nz_worley_manhattan(p, nbrs) :
|
||||
dist == "chebyshev" ? _nz_worley_chebyshev(p, nbrs) :
|
||||
dist == "border" ? _nz_worley_border(p, nbrs) :
|
||||
_nz_worley_classic(p, nbrs, dist);
|
||||
assert("Unknown distance option");
|
||||
|
||||
function _nz_worley2s(points, seed, grid_w, dist) =
|
||||
let(
|
||||
noise = dist == "euclidean" ? function(p, nbrs) _nz_worley_euclidean(p, nbrs) :
|
||||
dist == "manhattan" ? function(p, nbrs) _nz_worley_manhattan(p, nbrs) :
|
||||
dist == "chebyshev" ? function(p, nbrs) _nz_worley_chebyshev(p, nbrs) :
|
||||
dist == "border" ? function(p, nbrs) _nz_worley_border(p, nbrs) :
|
||||
assert("Unknown distance option")
|
||||
)
|
||||
[
|
||||
for(p = points)
|
||||
let(
|
||||
fcord = [floor(p.x / grid_w), floor(p.y / grid_w)],
|
||||
nbrs = _neighbors(fcord, seed, grid_w)
|
||||
)
|
||||
noise(p, nbrs)
|
||||
];
|
@ -13,4 +13,4 @@ use <_impl/_nz_worley2_impl.scad>;
|
||||
|
||||
function nz_worley2s(points, seed, grid_w = 10, dist = "euclidean") =
|
||||
let(sd = is_undef(seed) ? rand() : seed)
|
||||
[for(p = points) _nz_worley2(p, sd, grid_w, dist)];
|
||||
_nz_worley2s(points, sd, grid_w, dist);
|
Loading…
x
Reference in New Issue
Block a user