1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-07-31 20:10:36 +02:00
This commit is contained in:
Justin Lin
2020-04-06 09:21:53 +08:00
parent fd7cff8e57
commit 24157ceb24
9 changed files with 91 additions and 68 deletions

View File

@@ -192,8 +192,8 @@ See [examples](examples).
### Noise (2.3 Preview)
- [noise/nz_perlin1](https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin1.html)
- [noise/nz_perlin1s](https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin1s.html)
- noise/nz_perlin2
- noise/nz_perlin2s
- [noise/nz_perlin2](https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin2.html)
- [noise/nz_perlin2s](https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin2s.html)
- noise/nz_perlin3
- noise/nz_perlin3s
- noise/nz_worley1

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

37
docs/lib2x-nz_perlin2.md Normal file
View File

@@ -0,0 +1,37 @@
# nz_perlin2
Returns the 2D [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise) value at the (x, y) coordinate.
**Since:** 2.3
## Parameters
- `x` : The x coordinate.
- `y` : The y coordinate.
- `seed` : The random seed.
## Examples
use <util/rand.scad>;
use <hull_polyline2d.scad>;
use <function_grapher.scad>;
use <noise/nz_perlin2.scad>;
use <contours.scad>;
seed = rand(0, 255);
points = [
for(y = [0:.1:10])
[
for(x = [0:.1:10])
[x, y, nz_perlin2(x, y, seed)]
]
];
function_grapher(points, 1);
translate([11, 0])
for(isoline = contours(points, 0)) {
hull_polyline2d(isoline, width = .1);
}
![nz_perlin2](images/lib2x-nz_perlin2-1.JPG)

32
docs/lib2x-nz_perlin2s.md Normal file
View File

@@ -0,0 +1,32 @@
# nz_perlin2s
Returns 2D [Perlin noise](https://en.wikipedia.org/wiki/Perlin_noise) values at (x, y) coordinates.
**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.
## Examples
use <util/rand.scad>;
use <hull_polyline2d.scad>;
use <function_grapher.scad>;
use <noise/nz_perlin2s.scad>;
use <contours.scad>;
seed = rand(0, 255);
for(y = [0:.1:10]) {
points = [for(x = [0:.1:10]) [x, y]];
noises = nz_perlin2s(points, seed);
for(i = [0:len(points) - 1]) {
translate(points[i])
linear_extrude(noises[i] + 1)
square(.1);
}
}
![nz_perlin2s](images/lib2x-nz_perlin2s-1.JPG)

View File

@@ -1,18 +0,0 @@
use <hull_polyline2d.scad>;
use <util/rand.scad>;
use <experimental/zip.scad>;
use <noise/nz_perlin1.scad>;
use <noise/nz_perlin1s.scad>;
seed = rand();
hull_polyline2d(
[for(x = [0:.1:10]) [x, nz_perlin1(x, seed)]], width = .1
);
xs = [for(x = [0:.2:8.3]) x];
ys = nz_perlin1s(xs);
translate([0, 2])
hull_polyline2d(
zip([xs, ys]), width = .1
);

View File

@@ -1,48 +0,0 @@
use <util/rand.scad>;
use <function_grapher.scad>;
use <noise/nz_perlin2s.scad>;
module demo1() {
points = [
for(y = [0:.2:10])
for(x = [0:.2:10])
[x, y]
];
noise = nz_perlin2s(points);
for(i = [0:len(points) - 1]) {
c = (noise[i] + 1.1) / 2;
color([c, c, c])
translate(points[i])
square(.2);
}
}
module demo2() {
points = [
for(y = [0:.2:10])
[
for(x = [0:.2:10])
[x, y]
]
];
seed = rand(0, 256);
function_grapher(
[
for(ri = [0:len(points) - 1])
let(ns = nz_perlin2s(points[ri], seed))
[
for(ci = [0:len(ns) - 1])
[points[ri][ci][0], points[ri][ci][1], ns[ci]]
]
],
0.25)
;
}
demo1();
translate([12, 0])
demo2();

View File

@@ -1,3 +1,13 @@
/**
* nz_perlin2.scad
*
* @copyright Justin Lin, 2020
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin2.html
*
**/
use <util/rand.scad>;
use <noise/_impl/_pnoise2_impl.scad>;

View File

@@ -1,3 +1,13 @@
/**
* nz_perlin2s.scad
*
* @copyright Justin Lin, 2020
* @license https://opensource.org/licenses/lgpl-3.0.html
*
* @see https://openhome.cc/eGossip/OpenSCAD/lib2x-nz_perlin2s.html
*
**/
use <util/rand.scad>;
use <noise/_impl/_pnoise2_impl.scad>;