Subscribed unsubscribe Subscribe Subscribe

map()

processing_Sample

map()
map() \ Language (API) \ Processing 2+

x = map(value, d1,d2, d3,d4);

value in the domain [d1 to d2]
remap
x in the domain [d3 to d4]

d1,d2,d3,d4 and ReturnNum is """float"""

float value = 50;
float m = map(value, 0, 100, -20, -10);

print(m); // prints "-15.0"
void setup(){
  size(400,400);
}
void draw(){
  background(200);
  line(150,200,250,200);
  line(0,height-125, 400,height-125);
  
  float x1 = map(mouseX,0,width, 150,250);
  ellipse(x1, 200, 50,50);
  
  ellipse(mouseX, height-125, 50,50);
  line(x1,200,mouseX,height-125); 
}