Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Processing Chapter 3

ch 3
by

michael murray

on 21 October 2012

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Processing Chapter 3

Chapter 3: Interaction
Learning Processing
Daniel Shiffman

Presentation by Donald W. Smith
Graphics from text The Beginning Learning Processing: Slides by Don Smith Blocks of code can be named (aka ‘methods’)

methodName {
.. A bunch of ‘statements’;
}

Processing runs in a loop
Your write setup() and draw() methods

Processing tracks the mouse
Current X and Y
Previous X and Y

You can control processing using ‘methods’
background(), frameRate(), size(), smooth().. Summary Learning Processing: Slides by Don Smith Assignment 2: Learning Processing: Slides by Don Smith Things that you may use during setup():

size(200,200);
smooth();
frameRate(30); // defaults to 60 frames/sec
background(255); // clear the screen

Each may be used for their own purposes
Some may also be used in draw()methods

What would this do to your drawing if the background(255)call was in draw()? Processing setup()method 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 Mouse clicks and Key presses Learning Processing: Slides by Don Smith setup()and draw() are ‘methods’
Think of them as named ‘blocks’ of code
You get to write the code inside the ‘block’
New symbols and words! (just look for now)
void
()
//
{ } Using your first ‘methods’! Learning Processing: Slides by Don Smith Games are written with ‘loops’


Like running a race

Prepare (put on shoes…)
Loop putting feet forward over and over
Run until the race is over Program flow Learning Processing: Slides by Don Smith
Interaction

The “flow” of a program
The meaning behind setup() and draw()
Mouse interaction
Your first “dynamic” Processing program
Handling events
Mouse clicks
Key Presses The Beginning Just keep connecting the points where the
mouse was and it is now: Learning Processing: Slides by Don Smith A scribble application Learning Processing: Slides by Don Smith 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 More Mouse tracks… Learning Processing: Slides by Don Smith 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: Tracking the Mouse Learning Processing: Slides by Don Smith When does processing ‘paint’ the screen? The ‘invisible’ line of code… Learning Processing: Slides by Don Smith A ‘block’ of code Parts of a program are separated into blocks
In Java, C, C++, PHP and many other languages:
Blocks are surrounded by curly braces: { ….. }
Think of blocks like an outline set of sub-steps:
1
1a
1b
2

Programmers (and editors) line up code in blocks
Usually indent the ‘statements’ inside the block All of your code can go into two ‘blocks’: Code for Zoog as a dynamic sketch Try these void setup() {
size(200,200);
}
void draw() {
background(255);
line(mouseX, mouseY, 100,100);
} Learning Processing: Slides by Don Smith void setup() {
size(200,200);
background(255);
}
void draw() {
line(mouseX, mouseY, 100,100);
} Using background(255) No Yes Done yet? Program ends Call draw() Call setup() Program Starts Learning Processing: Slides by Don Smith When your program starts, Processing:
Calls setup() once
Continues to call draw() untill the program ends setup() and draw() methods Chapter 3: Interaction
Learning Processing
Daniel Shiffman

Presentation by Donald W. Smith
Graphics from text Learning Processing: Slides by Don Smith 1: Pixels
2: Processing
3: Interaction
The “flow” of a program
The meaning behind setup() and draw()
Mouse interaction
Your first “dynamic” Processing program
Handling events
Mouse clicks
Key Presses Lesson One: The Beginning Learning Processing: Slides by Don Smith Games are written with ‘loops’
Like running a race
Prepare (put on shoes…)
Loop putting feet forward over and over
Run until the race is over

Remember that programs are made of parts:
Sequential
Conditional
Iterative Program flow Learning Processing: Slides by Don Smith Parts of a program are separated into blocks
In Java, C, C++, PHP and many other languages:
Blocks are surrounded by curly braces: { ….. }
Think of blocks like an outline set of sub-steps:
1
1a
1b
2


Programmers (and editors) line up code in blocks
Usually indent the ‘statements’ inside the block A ‘block’ of code Learning Processing: Slides by Don Smith Parts of a program are separated into blocks
In Java, C, C++, PHP and many other languages:
Blocks are surrounded by curly braces: { ….. }
Think of blocks like an outline set of sub-steps:
1
1a
1b
2

Programmers (and editors) line up code in blocks
Usually indent the ‘statements’ inside the block A ‘block’ of code Learning Processing: Slides by Don Smith setup()and draw()are ‘methods’
Think of them as named ‘blocks’ of code
You get to write the code inside the ‘block’
New symbols and words! (just look for now)
void
()
//
{ } Using your first ‘methods’! Learning Processing: Slides by Don Smith Games are written with ‘loops’
Like running a race
Prepare (put on shoes…)
Loop putting feet forward over and over
Run until the race is over
Remember that programs are made of parts:
Sequential
Conditional
Iterative Program flow Chapter 3: Interaction
Learning Processing
Daniel Shiffman

Presentation by Donald W. Smith
Graphics from text Lesson One: The Beginning Learning Processing: Slides by Don Smith 1: Pixels
2: Processing
3: Interaction
The “flow” of a program
The meaning behind setup() and draw()
Mouse interaction
Your first “dynamic” Processing program
Handling events
Mouse clicks
Key Presses Lesson One: The Beginning
Full transcript