()
| 16 | } |
| 17 | |
| 18 | function draw() { |
| 19 | // Color the background and draw lines to divide the window in quadrants. |
| 20 | background(r, g, b); |
| 21 | stroke(0); |
| 22 | line(width / 2, 0, width / 2, height); |
| 23 | line(0, height / 2, width, height / 2); |
| 24 | |
| 25 | // If the mouse is on the right hand side of the window, increase red. |
| 26 | // Otherwise, it is on the left hand side and decrease red. |
| 27 | if (mouseX > width / 2) { |
| 28 | r = r + 1; |
| 29 | } else { |
| 30 | r = r - 1; |
| 31 | } |
| 32 | |
| 33 | // If the mouse is on the bottom of the window, increase blue. |
| 34 | // Otherwise, it is on the top and decrease blue. |
| 35 | if (mouseY > height / 2) { |
| 36 | b = b + 1; |
| 37 | } else { |
| 38 | b = b - 1; |
| 39 | } |
| 40 | |
| 41 | // If the mouse is pressed (using the system variable mousePressed) |
| 42 | if (isMousePressed()) { |
| 43 | g = g + 1; |
| 44 | } else { |
| 45 | g = g - 1; |
| 46 | } |
| 47 | |
| 48 | // Constrain all color values to between 0 and 255. |
| 49 | r = constrain(r, 0, 255); |
| 50 | g = constrain(g, 0, 255); |
| 51 | b = constrain(b, 0, 255); |
| 52 | } |
nothing calls this directly
no test coverage detected