320 likes | 420 Views
Lab Hours. Thanks for your responses! I'll send out an e-mail by the end of the day with with lab hours.And always feel free to e-mail me if you have questions. I'm at gtg362v@mail.gatech.edu . (If you forget, it'll be on the whiteboard in here.). http://www.lcc.gatech.edu/~mateas/courses/LCC6310
E N D
1. Computation as an Expressive Medium Lab 1: Loops, Animation, and Simple User Interaction
Jason Alderman
*Slides blatantly stolen from Mayhew Seavey. Yoinks!
2. Lab Hours Thanks for your responses! Ill send out an e-mail by the end of the day with with lab hours.
And always feel free to e-mail me if you have questions. Im at gtg362v@mail.gatech.edu .
(If you forget, itll be on the whiteboard in here.)
3. What have you gone over? Window size and coordinate system
Commenting code
Variables
Drawing primitives
point
line
rect
ellipse
triangle
print() and println()
if(boolean){ do something }else{ do something} logic
4. What will we go over? Courseware!
Variables: A Recap
Drawing primitives (more info)
Java Control Flow: Looping
The Processing draw() looping function for animation
Simple mouse interaction
5. Variables Variables are placeholders for your data.
6. Variables Two main types: Primitives and Objects
Primitives:
Boolean, Char, Byte, Short, Int, Long, Float, Double
Objects:
Everything else.
Constructed with primitives as a base. For example, a String object is a series of Char variables.
7. More info on drawing primitives Zooooom on over to the reference pages
8. Java Control Flow If-Then-Else: Conditional Logic
9. Java Control Flow: Looping Want to draw ten lines, evenly-spaced apart?
10. Java Control Flow: Looping Want to draw ten lines, evenly-spaced apart?
11. Java Control Flow: While Loops Holy Toledo! We can! Lets use a while loop!
12. Java Control Flow: While Loops Be careful with loops. Make sure the condition will eventually return false, or else it will go forever.
13. Java Control Flow: For Loops For Loops are just like While loops, but a bit more compact for simple incrementing, like in our last example.
These two loops are functionally the same:
14. Java Control Flow: Nested Loops Nesting of loops refers to putting one loop inside the brackets of another.
15. Java Control Flow: Nested Loops Still confused? Lets look at this thing closer.
16. Java Control Flow: Nested Loops Still confused? Lets look at this thing closer.
17. Java Control Flow: Nested Loops Still confused? Lets look at this thing closer.
18. Java Control Flow: Nested Loops Still confused? Lets look at this thing closer.
19. Java Control Flow: Nested Loops Still confused? Lets look at this thing closer.
20. Java Control Flow: Nested Loops Still confused? Lets look at this thing closer.
21. Java Control Flow: Nested Loops Still confused? Lets look at this thing closer.
22. Java Control Flow: Nested Loops Still confused? Lets look at this thing closer.
23. Java Control Flow: Nested Loops Still confused? Lets look at this thing closer.
24. Java Control Flow: Nested Loops Nested Loops are especially useful for drawing in grid formations in a 2-D space.
Think about how you could nest another loop inside to make a grid in a 3-D space.
25. The draw() function What is the draw() function?
Processing allows you to put code in a special function called draw, which will run a number of times per second.
For any graphics that you want to change over time, or have the user interact with, youll need to use the draw() function.
26. The draw() function Simple example:
27. The draw() function Simple example:
28. The draw() function Simple example:
29. The draw() function Simple example:
30. The setup() function You can use the setup() function to define some properties of your window once when your program first starts:
size(width, height): size of drawing window (in pixels)
framerate(fps): number of times per second that the draw() function is called.
31. Tracking Mouse Position Processing uses two global variables which have the current mouse position at all times:
mouseX, mouseY: current X and Y of cursor, relative to the top-left of drawing window.
32. Reacting to Mouse Clicks Use the variable mousePressed.
33. Thats It For Today! For and While Loops
Processing draw() function
Mouse Position and Clicking