Linear interpolation (sometimes called 'lerp' or 'mix') is a really handy function for creative coding, gamedev and generative art.
The function interpolates within the range [start..end] based on a 't' parameter, where 't' is typically within a [0..1] range.
A thread...
For example, divide 'loop time' by 'loop duration' and you get a 't' value between 0..1.
Now you can map this 't' value to a new range, such as `lerp(20, 50, t)` to gradually increase a circle's radius, or `lerp(20, 10, t)` to gradually decrease its line thickness.
Jul 2, 2018 • 11 tweets • 5 min read
A function that produces a scribble. #generative#code#javascript
So many of my sketches begin with the same function: producing a uniform distribution of values along an array, between [0..1] range. Here's how it looks in JavaScript.
I'm calling it "arcs" (for arc lengths) but perhaps there is a proper name for this sort of thing?