Home‎ > ‎Unit 04‎ > ‎

Mouse Input

In this unit we will add our first unser input. What I mean by this is you do stuff while the program is running and it responds to you! We're continuing through chapter 5 of Getting Started with Processing. The video below walks you through examples 5-4 thru 5-6. Watch the video, read 53-55, and play with the program examples. Changing things up a bit and see what happens.

Example 5-7 introduces the dist() function. Basically dist() simply finds the distance between any two points. Try the program below to see how it works. 
Try out Example 5-7. Play with it and see if you can make it cooler.

Assignment 4.1: Modify Example 5-7 to use dist() to change the color of your line.
Assignment 4.2: Work through Examples 5-8 and 5-9. Write an explanation of how easing works in your own words and post to your blog.

Another very useful function is map(). Map is used to rescale variables. You can think of it as dimensional analysis without all the mind-numbingness. The video below describes how map works.

Map has 5 parameters:

 map(number to convert, smallest possible number, biggest possible, new smallest, new biggest)
Reproduce my code for an "eye" and tweak it a bit to make it work better. You can even map things backwards if you want. Swap the positions of the new smallest and new biggest and see what happens. Also work through examples 5-10 and 5-11 from the book. Once you've done that then try Assignment 4.3

Assignment 4.3: Make a silly face with two eyes that follow the mouse. As usual, post commented code to your blog.