mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-11 09:14:29 +02:00
add doc
This commit is contained in:
BIN
docs/images/lib2x-nz_worley2s-1.JPG
Normal file
BIN
docs/images/lib2x-nz_worley2s-1.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
BIN
docs/images/lib2x-nz_worley2s-2.JPG
Normal file
BIN
docs/images/lib2x-nz_worley2s-2.JPG
Normal file
Binary file not shown.
After Width: | Height: | Size: 47 KiB |
43
docs/lib2x-nz_worley2s.md
Normal file
43
docs/lib2x-nz_worley2s.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# nz_worley2s
|
||||
|
||||
Returns 2D [Worley noise](https://en.wikipedia.org/wiki/Worley_noise) values `[cell_x, cell_y, noise]` at (x, y) coordinates.
|
||||
|
||||
It divides the space into tiles. The nucleus of each cell is randomly placed in a tile.
|
||||
|
||||

|
||||
|
||||
**Since:** 2.3
|
||||
|
||||
## Parameters
|
||||
|
||||
- `points` : A list of `[x, y]` coordinates.
|
||||
- `seed` : The random seed. If it's ignored, a randomized value will be used.
|
||||
- `tile_w` : The tile width. Default to 10. Smaller `tile_w` makes more cells.
|
||||
- `dist` : The noise value of each point is based on its distance to other cells. Different distance strategies make different noises. The `dist` parameter accepts `"euclidean"`, `"manhattan"`, `"chebyshev"` or `"border"`.
|
||||
|
||||
## Examples
|
||||
|
||||
use <noise/nz_worley2s.scad>;
|
||||
|
||||
size = [100, 50];
|
||||
tile_w = 10;
|
||||
dist = "euclidean"; // [euclidean, manhattan, chebyshev, border]
|
||||
seed = 51;
|
||||
|
||||
points = [
|
||||
for(y = [0:size[1] - 1])
|
||||
for(x = [0:size[0] - 1])
|
||||
[x, y]
|
||||
];
|
||||
|
||||
cells = nz_worley2s(points, seed, tile_w, dist);
|
||||
|
||||
for(i = [0:len(cells) - 1]) {
|
||||
h = norm([cells[i][0], cells[i][1]]) % 10;
|
||||
color([h, h, h] / 10)
|
||||
linear_extrude(h)
|
||||
translate(points[i])
|
||||
square(1);
|
||||
}
|
||||
|
||||

|
Reference in New Issue
Block a user