Learn creative coding writing simple programs

96. Easier mouse in a rectangle

Using rectMode(CENTER) makes it harder to find out if the mouse is inside a square. If we use rectMode(CORNERS) the program becomes much simpler because we don't need to calculate the position of the four walls of our rectangle: we already know them.
In this episode we also see a small example of how we can generate colors that have the same hue but a different brightness or saturation.

Tags: rect, inside, mouse, point

Code editor

You can make changes to the code below. Then

Questions and comments

Try to stay close to the topic of this episode. Use the Processing forums for help with unrelated Processing projects (or hire me for help ;-)

To indicate that a word in your comment is code, use the `backtick`. Example
  Do `float` and `int` smell similar?
To highlight code blocks, use ```processing and ``` like this:
  ```processing
  void setup() {
    size(600, 600);
  }
  ```