- Arguments
`[x]`

`[x y]`

`[x y z]`

- Docstring
Returns the Perlin noise value at specified coordinates. Perlin noise is a random sequence generator producing a more natural ordered, harmonic succession of numbers compared to the standard random function. It was invented by Ken Perlin in the 1980s and been used since in graphical applications to produce procedural textures, natural motion, shapes, terrains etc.

The main difference to the random function is that Perlin noise is defined in an infinite n-dimensional space where each pair of coordinates corresponds to a fixed semi-random value (fixed only for the lifespan of the program). The resulting value will always be between 0.0 and 1.0. Processing can compute 1D, 2D and 3D noise, depending on the number of coordinates given. The noise value can be animated by moving through the noise space and the 2nd and 3rd dimensions can also be interpreted as time.

The actual noise is structured similar to an audio signal, in respect to the function's use of frequencies. Similar to the concept of harmonics in physics, perlin noise is computed over several octaves which are added together for the final result.

Another way to adjust the character of the resulting sequence is the scale of the input coordinates. As the function works within an infinite space the value of the coordinates doesn't matter as such, only the distance between successive coordinates does (eg. when using noise within a loop). As a general rule the smaller the difference between coordinates, the smoother the resulting noise sequence will be. Steps of 0.005-0.03 work best for most applications, but this will differ depending on use.

- Example
(q/background 255) (q/fill 0) (q/text (str "(q/noise 42) = " (q/noise 42)) 10 20) (q/text (str "(q/noise 1 2) = " (q/noise 1 2)) 10 40) (q/text (str "(q/noise 50 10 3) = " (q/noise 50 10 3)) 10 60)

try example

- Arguments
`[octaves]`

`[octaves falloff]`

- Docstring
Adjusts the character and level of detail produced by the Perlin noise function. Similar to harmonics in physics, noise is computed over several octaves. Lower octaves contribute more to the output signal and as such define the overall intensity of the noise, whereas higher octaves create finer grained details in the noise sequence. By default, noise is computed over 4 octaves with each octave contributing exactly half than its predecessor, starting at 50% strength for the 1st octave. This falloff amount can be changed by adding an additional function parameter. Eg. a falloff factor of 0.75 means each octave will now have 75% impact (25% less) of the previous lower octave. Any value between 0.0 and 1.0 is valid, however note that values greater than 0.5 might result in greater than 1.0 values returned by noise.

By changing these parameters, the signal created by the noise function can be adapted to fit very specific needs and characteristics.

- Works only inside sketch functions?
- Yes
- Original Processing method
- noiseDetail()
- Original p5js method
- noiseDetail()

- Example
(q/background 255) (q/fill 0) (q/noise-detail 3) (q/text (str "(q/noise 42) = " (q/noise 42)) 10 20) (q/noise-detail 5 0.5) (q/text (str "(q/noise 42) = " (q/noise 42)) 10 40)

try example

- Arguments
`[val]`

- Docstring
Sets the seed value for noise. By default, noise produces different results each time the program is run. Set the

`val`

parameter to a constant to return the same pseudo-random numbers each time the software is run.

- Works only inside sketch functions?
- Yes
- Original Processing method
- noiseSeed()
- Original p5js method
- noiseSeed()

- Example
(q/background 255) (q/fill 0) (q/noise-seed 42) (q/text (str "(q/noise 42) = " (q/noise 42)) 10 20)

try example

- Arguments
`[max]`

`[min max]`

- Docstring
Generates random numbers. Each time the random function is called, it returns an unexpected value within the specified range. If one parameter is passed to the function it will return a

`float`

between zero and the value of the high parameter. The function call`(random 5)`

returns values between 0 and 5 (starting at zero, up to but not including 5). If two parameters are passed, it will return a`float`

with a value between the parameters. The function call`(random -5 10.2)`

returns values starting at -5 up to (but not including) 10.2.

- Example
(q/background 255) (q/fill 0) (q/text (str "(q/random 42) = " (q/random 42)) 10 20) (q/text (str "(q/random Math/E q/PI) = " (q/random Math/E q/PI)) 10 40)

try example

- Arguments
`[]`

- Docstring
Returns a new 2D unit vector with a random direction

- Works only inside sketch functions?
- Yes
- Original Processing method
- None.
- Original p5js method
- None.

- Example
(q/background 255) (q/fill 0) (q/text (str "(q/random-2d) = " (q/random-2d)) 10 20) (letfn [(unit-vector? [v] (let [n (->> v (map q/sq) (apply +))] (< (Math/abs (- n 1.0)) 0.001)))] (dotimes [_ 100] (when-not (unit-vector? (q/random-2d)) (throw (ex-info "random-2d doesn't return a unit vector" {})))))

try example

- Arguments
`[]`

- Docstring
Returns a new 3D unit vector with a random direction

- Works only inside sketch functions?
- Yes
- Original Processing method
- None.
- Original p5js method
- None.

- Example
(q/background 255) (q/fill 0) (q/text (str "(q/random-3d) = " (q/random-3d)) 10 20) (letfn [(unit-vector? [v] (let [n (->> v (map q/sq) (apply +))] (< (Math/abs (- n 1.0)) 0.001)))] (dotimes [_ 100] (when-not (unit-vector? (q/random-3d)) (throw (ex-info "random-3d doesn't return a unit vector" {})))))

try example

- Arguments
`[]`

- Docstring
Returns a

`float`

from a random series of numbers having a mean of 0 and standard deviation of 1. Each time the random-gaussian function is called, it returns a number fitting a Gaussian, or normal, distribution. There is theoretically no minimum or maximum value that random-gaussian might return. Rather, there is just a very low probability that values far from the mean will be returned; and a higher probability that numbers near the mean will be returned.

- Works only inside sketch functions?
- Yes
- Original Processing method
- randomGaussian()
- Original p5js method
- randomGaussian()

- Example
(q/background 255) (q/fill 0) (q/text (str "(q/random-gaussian) = " (q/random-gaussian)) 10 20)

try example

- Arguments
`[w]`

- Docstring
Sets the seed value for random. By default, random produces different results each time the program is run. Set the value parameter to a constant to return the same pseudo-random numbers each time the software is run.

- Works only inside sketch functions?
- Yes
- Original Processing method
- randomSeed()
- Original p5js method
- randomSeed()

- Example
(q/background 255) (q/fill 0) (q/random-seed 42) (q/text (str "(q/random 42) = " (q/random 42)) 10 20)

try example