We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
map() (Read 604 times)
map()
Mar 21st, 2010, 7:17am
 
Can anyone explain what "map()" does? The reference is not clear.
Re: map()
Reply #1 - Mar 21st, 2010, 7:40am
 
b = map(a, min1, max1, min2, max2);

takes a value of a in the range (min1, max1), and then calculates where in the range min2, max2 it falls....

So map(5, 0, 10, 20, 40) should return 30..... just saves you writing your own conversion equations when for example, you want to get a value from 0 to width (e.g. mouseX) and map it to the values 0-255 (alpha, say).

alpha = map(mouseX, 0, width, 0, 255);

Understood
Reply #2 - Mar 21st, 2010, 11:34am
 
Got it, appreciated, thanks Wink
Page Index Toggle Pages: 1