Skip to content

Commit 080be4f

Browse files
committed
Updates to the new Map example and add it to the main list
1 parent c59f196 commit 080be4f

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

  • content/examples/Basics/Math/Map

content/examples/Basics/Math/Map/Map.pde

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Map.
3-
*
3+
*
44
* Use the map() function to take any number and scale it to a new number
55
* that is more useful for the project that you are working on. For example, use the
66
* numbers from the mouse position to control the size or color of a shape.
@@ -15,10 +15,9 @@ void setup() {
1515

1616
void draw() {
1717
background(0);
18-
// mouseX has a min of 0 and a max of 640 (the width of the window)
19-
// here we are scaling that variable from 0 to 640 to a number between 0 and 255
18+
// Scale the mouseX value from 0 to 640 to a range between 0 and 175
2019
float c = map(mouseX, 0, width, 0, 175);
21-
// here we are scaling that same variable to a range between 40 and 440
20+
// Scale the mouseX value from 0 to 640 to a range between 40 and 300
2221
float d = map(mouseX, 0, width, 40, 300);
2322
fill(255, c, 0);
2423
ellipse(width/2, height/2, d, d);

0 commit comments

Comments
 (0)