User Tools

Site Tools


courses:2008.23.09.intro_prototyping

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

courses:2008.23.09.intro_prototyping [2008/10/22 13:18] (current)
camille created
Line 1: Line 1:
 +====== oct 23: Introduction to programming with Processing: Inputs, mouse, keystrokes, audio, video. ======
  
 +
 +==== Conditional statements ====
 +
 +//if// condition
 +<​code>​
 +if (test) { 
 +  statements ​
 +}
 +</​code>​
 +
 +//else// condition
 +<​code>​
 +if(expression) { 
 +  statements ​
 +} else { 
 +  statements ​
 +
 +
 +// also possible
 +
 +if(expression) { 
 +  statements ​
 +} else if(expression) { 
 +  statements ​
 +} else { 
 +  statements ​
 +}
 +</​code>​
 +
 +==== Operators ====
 +
 +<​code>​
 +&& (logical AND)
 +! (logical NOT)
 +|| (logical OR)
 +
 +== (equality)
 +> (greater than)
 +>= (greater than or equal to)
 +!= (inequality)
 +< (less than)
 +<= (less than or equal to)
 +</​code>​
 +
 +
 +
 +
 +
 +==== Inputs ====
 +
 +How to control the code and build your logic/​process/​structure
 +
 +== Mouse ==
 +  * //​mouseButton//​ accessible directly in the draw function //​mousePressed//​ or in its own function //​mousePressed()//​
 +  * //​mouseReleased()//,​ //​mouseMoved()//​ and //​mouseDragged()//​ also available
 +  * mouse coordinates:​ //mouseX// and //mouseY//
 +  * mouse coordinates of the previous frame: //pmouseX// and //pmouseY//
 +
 +== Keystroke ==
 +
 +  * //key// vs //keyCode//
 +  * //​keyPressed()//​ and //​keyReleased()//​
 +
 +== Audio ==
 +
 +  * Using the Mimim library (included in Processing version 0152 and later)
 +  * See the included example Minim -> getLineIn
 +
 +== Video ==
 +
 +  * using the default Video library (please read all the information on the [[http://​processing.org/​reference/​libraries/​video/​index.html|video page]])
 +<​code>​
 +import processing.video.*;​
 +Capture myCapture;
 +
 +void setup() ​
 +{
 +  size(640, 480);
 +
 +  myCapture = new Capture(this,​ width, height, 30);
 +  ​
 +  // open the control panel for this device
 +  myCapture.settings();​
 +  ​
 +  // The name of the capture device is dependent those
 +  // plugged into the computer. To get a list of the 
 +  // choices, uncomment the following line 
 +  // println(Capture.list());​
 +  // And to specify the camera, replace "​Camera Name" ​
 +  // in the next line with one from Capture.list()
 +  // myCapture = new Capture(this,​ width, height, "​Camera Name", 30);
 +}
 +
 +void captureEvent(Capture myCapture) {
 +  myCapture.read();​
 +}
 +
 +void draw() {
 +  image(myCapture,​ 0, 0);
 +}
 +</​code>​
 +
 +== Others ==
 +
 +  * Sudden Motion Sensor Library (Apple laptops) [[http://​www.shiffman.net/​p5/​sms]]
 +  * QR Code (two-dimensional barcode) using video capture [[http://​www.shiffman.net/​p5/​pqrcode]]
 +  * many more ...
courses/2008.23.09.intro_prototyping.txt · Last modified: 2008/10/22 13:18 by camille