Introduction to Processing Dominique Thiebaut Dept. Computer Science Computer Science Dominique Thiebaut Thiebaut -- Computer Science
Who? Where? Why? Ben Fry & Casey Reas MIT Media Labs Computer Science Dominique Thiebaut Processing is a programming language and environment built for the media arts communities. It is created to teach fundamentals of computer programming within the media arts context and to serve as a software sketchbook. It is used by students, artists, designers, architects, and researchers for learning, prototyping, and production.
Ben Fry on Processing... Computer Science Dominique Thiebaut
= GREAT RESOURCE! Mouse 2D Example html html Computer Science Dominique Thiebaut An Example
How does it Work? Computer Science Dominique Thiebaut
How does it Work? Java Java independen t of operating system Processing works on Windows, Mac, Linux Computer Science Dominique Thiebaut
Writing a Sketch Computer Science Dominique Thiebaut
Writing a Sketch Computer Science Dominique Thiebaut Functions User functions Library functions Predefined: setup() draw() mouseX mouseY
Run/Stop Computer Science Dominique Thiebaut
Learning Processing (Learning Java Syntax) Computer Science Dominique Thiebaut
Some Examples Assembly language programs Graphics/Interactive programs Computer Science Dominique Thiebaut
Assembly Language Example 1 Computer Science Dominique Thiebaut Add two variables and store their sum into a third variable void setup() { int a = 10; int b = 20; int c = 0; c = a+b; println(“c= “ + c); }
Example 2 Computer Science Dominique Thiebaut Write an infinite loop that prints all the positive integers. void setup() { int count = 1; while (true) { println(count); count = count+1; }
void setup() { int count = 1; while (true) { println(count); count = count+1; } Example 2 Computer Science Dominique Thiebaut Write an infinite loop that prints all the positive integers.
void setup() { int count = 1; while (true) { println(count); count = count+1; } Example 2 Computer Science Dominique Thiebaut Write an infinite loop that prints all the positive integers.
Example 3 Computer Science Dominique Thiebaut Write an loop that prints all the integers from 1 to 10. void setup() { int count = 1; while ( ) { println(count); count = count+1; }
void setup() { int count = 1; while (count<=10) { println(count); count = count+1; } Example 3 Computer Science Dominique Thiebaut Write an loop that prints all the integers from 1 to 10.
void setup() { int count = 1; int sum = 0; while ( ) { } Example 4 Computer Science Dominique Thiebaut Write an loop that computes the sum of all the integers from 1 to 10 and prints the result.
void setup() { int count = 1; int sum = 0; while (count<=10) { sum = sum+count; count = count+1; } println(“sum=”+sum); } Example 4 Computer Science Dominique Thiebaut Write an loop that computes the sum of all the integers from 1 to 10 and prints the result.
Some Examples Assembly language programs Graphics/Interactive programs Computer Science Dominique Thiebaut
First Graphics Program void setup() { size(480, 480); smooth(); } void draw() { ellipse(mouseX, mouseY, 80, 80); } Computer Science Dominique Thiebaut
Some Variations to Try Lookup the rect() function in the Processing.org reference section. Replace the ellipse by a rectangle Lookup the background() function and place it in draw() Fill the ellipse or rectangle with a color using the fill() function Computer Science Dominique Thiebaut
Computer Science Dominique Thiebaut