Returns a Jitterer that works with absolute values, ie. values outside of 0..1 range.
Jitter amount is absolute, meaning a fixed value regardless of input value, or relative, meaning it is scaled according to input value.
// Jitter by -10 to +10 (absolute value: 10)const j1 = jitterAbsolute({ absolute: 10 });j1(100); // Produces range of 90...110// Jitter by -20 to +20 (relative value 20%)const j2 = jitterAbsolute({ relative: 0.20 });j2(100); // Produces a range of -80...120 Copy
// Jitter by -10 to +10 (absolute value: 10)const j1 = jitterAbsolute({ absolute: 10 });j1(100); // Produces range of 90...110// Jitter by -20 to +20 (relative value 20%)const j2 = jitterAbsolute({ relative: 0.20 });j2(100); // Produces a range of -80...120
The expected used case is calling jitterAbsolute to set up a jitterer and then reusing it with different input values, as above with the j1 and j2.
jitterAbsolute
j1
j2
However to use it 'one-off', just call the returned function immediately:
const v = jitterAbsolute({ absolute: 10 })(100); // v is in range of 90-110 Copy
const v = jitterAbsolute({ absolute: 10 })(100); // v is in range of 90-110
When clamped is true, return value is clamped to 0...value. That is, rather than the usual bipolar jittering, the jittering only goes below.
clamped
const j = jitterAbsolute({ absolute: 10, clamped: true })j(100); // Produces range of 90-100 Copy
const j = jitterAbsolute({ absolute: 10, clamped: true })j(100); // Produces range of 90-100
Returns a Jitterer that works with absolute values, ie. values outside of 0..1 range.
Jitter amount is absolute, meaning a fixed value regardless of input value, or relative, meaning it is scaled according to input value.
The expected used case is calling
jitterAbsolute
to set up a jitterer and then reusing it with different input values, as above with thej1
andj2
.However to use it 'one-off', just call the returned function immediately:
When
clamped
is true, return value is clamped to 0...value. That is, rather than the usual bipolar jittering, the jittering only goes below.