Name

map()

Examples
# Map between positive values. 
value = 50
m = map(value, 0, width, 0, width/2)
# Draw white ellipse at original x location. 
ellipse(value, height *.25, 10, 10)
# Draw black ellipse at mapped x location
fill(0)
ellipse(m, height*.75, 10, 10)
value = 110
m = map(value, 0, 100, -20, -10)
print(m)# Prints "-9.0"
def setup(): 
    size(200, 200)
    noStroke()

def draw(): 
    background(204)
    x1 = map(mouseX, 0, width, 50, 150)
    ellipse(x1, 75, 50, 50)
    x2 = map(mouseX, 0, width, 0, 200)
    ellipse(x2, 125, 50, 50)
Description
Syntax
map(value, start1, stop1, start2, stop2)
Parameters
value
start1
stop1
start2
stop2
Related norm()
lerp()
Updated on Wed Jan 18 17:32:20 2017.
Creative Commons License