1 / 8

TECH 3601 New Media Programming

TECH 3601 New Media Programming . Chapter 3 Interaction. setup() and draw() methods. Program Starts. When your program starts, Processing: Calls setup() once Continues to call draw() until the program ends. Call setup(). Call draw(). No. Done yet?. Yes. Program ends.

hue
Download Presentation

TECH 3601 New Media Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TECH 3601 New Media Programming Chapter 3 Interaction

  2. setup()and draw()methods Program Starts • When your program starts, Processing: • Calls setup() once • Continues to call draw() until the program ends Call setup() Call draw() No Done yet? Yes Program ends Learning Processing: Slides by Don Smith

  3. Tracking the Mouse • Processing keeps track of where the mouse is: • mouseX: The current X coordinate of the mouse • mouseY: The current Y coordinate of the mouse • These are both ‘key words’ that you can use! • Their values change as the mouse moves • An example: Learning Processing: Slides by Don Smith

  4. More Mouse tracks… • Processing also keeps track of where the mouse WAS the last time you left draw(): • pmouseX: The previous X coordinate of the mouse • pmouseY: The previous Y coordinate of the mouse Learning Processing: Slides by Don Smith

  5. A scribble application • Just keep connecting the points where the mouse was and it is now: Learning Processing: Slides by Don Smith

  6. Exercise • To get the absolute value: abs(-5)  5 • The speed at which the mouse is moving is: • abs(mouseX - pmouseX) • Update the previous example so that the faster the user moves the mouse, the wider the drawn line. • Hint: look up strokeWeight() in the Processing reference.

  7. Mouse clicks and Key presses • Two ‘methods’ that you can write to handle events that might happen: • Processing ‘calls’ your method when events occur: • mousePressed() • keyPressed() Learning Processing: Slides by Don Smith

More Related