|
| 1 | +###### Protocol |
| 2 | + |
| 3 | +# `Noise` |
| 4 | +A procedural noise generator. |
| 5 | + |
| 6 | +*** |
| 7 | + |
| 8 | +## Symbols |
| 9 | + |
| 10 | +### Initializers |
| 11 | + |
| 12 | +#### `init(amplitude:Double, frequency:Double, seed:Int)` |
| 13 | +> Creates an instance with the given `amplitude`, `frequency`, and random `seed` values. Creating an instance generates a new pseudo-random permutation table for that instance, and a new instance does not need to be regenerated to sample the same procedural noise field. |
| 14 | +
|
| 15 | +### Instance methods |
| 16 | + |
| 17 | +#### `func` `evaluate(_ x:Double, _ y:Double) -> Double` |
| 18 | +> Evaluates the noise field at the given coordinate. For three-dimensional and higher noise fields, the `z` and `w` coordinates, if applicable, are set to zero. |
| 19 | +
|
| 20 | +#### `func` `evaluate(_ x:Double, _ y:Double, _ z:Double) -> Double` |
| 21 | +> Evaluates the noise field at the given coordinate. For two-dimensional noise fields, the `z` coordinate is ignored. For four-dimensional noise fields, the `w` coordinate is set to zero. |
| 22 | +
|
| 23 | +#### `func` `evaluate(_ x:Double, _ y:Double, _ z:Double, _ w:Double) -> Double` |
| 24 | +> Evaluates the noise field at the given coordinate. For three-dimensional and lower noise fields, the `z` and `w` coordinates are ignored, if necessary. No existing noise generator in the library currently supports true four-dimensional evaluation. |
| 25 | +
|
| 26 | +#### `func` `sample_area(width:Int, height:Int) -> [(Double, Double, Double)]` |
| 27 | +> Evaluates the noise field over the given area, starting from the origin, and extending over the first quadrant, taking unit steps in both directions. Although the `x` and `y` coordinates are returned, the output vector is guaranteed to be in row-major order. |
| 28 | +
|
| 29 | +#### `func` `sample_area_saturated_to_u8(width:Int, height:Int, offset:Double = 0.5) -> [UInt8]` |
| 30 | +> Evaluates the noise field over the given area, starting from the origin, and extending over the first quadrant, storing the values in a row-major array of samples. The samples are clamped, but not scaled, to the range `0 ... 255`. |
| 31 | +
|
| 32 | +#### `func` `sample_volume(width:Int, height:Int, depth:Int) -> [(Double, Double, Double, Double)]` |
| 33 | +> Evaluates the noise field over the given volume, starting from the origin, and extending over the first octant, taking unit steps in all three directions. Although the `x`, `y`, and `z` coordinates are returned, the output vector is guaranteed to be in `xy`-plane-major, and then row-major order. |
| 34 | +
|
| 35 | +#### `func` `sample_volume_saturated_to_u8(width:Int, height:Int, depth:Int, offset:Double = 0.5) -> [UInt8]` |
| 36 | +> Evaluates the noise field over the given volume, starting from the origin, and extending over the first octant, storing the values in a `xy`-plane-major, and then row-major order array of samples. The samples are clamped, but not scaled, to the range `0 ... 255`. |
0 commit comments