Fun Programming with Processing 045 Convert distances into colors or widths
432 2021-08-03 Download
The map() function is very useful when you want to convert numbers from one range to another range. When do we want to do that? well, we use different ranges of numbers for different things. For example the sin() function returns values between -1 and 1. The valid X positions for drawing on our screen might be between 0 and 400. The right values for RGB colors usually are between 0 and 255.
Sometimes we want to make the color depend on a distance, or maybe the width depend on a speed. You can link any two concepts that come into your mind in your program. Using map() is the easiest way to convert values from one range to another.
Courtesy of Abe Pazos Solatie(Fun Programming)
Abe Pazos Solatie, artist and creative coder producing static, moving and interactive images with a focus on the subtle and the organic.