240 likes | 252 Views
Computer Science. Dominique Thiebaut. Introduction to Processing. Dominique Thiebaut Dept. Computer Science. Thiebaut -- Computer Science. Computer Science. Dominique Thiebaut. Who? Where? Why?. Ben Fry & Casey Reas MIT Media Labs.
E N D
Computer Science Dominique Thiebaut Introduction to Processing • Dominique Thiebaut • Dept. Computer Science Thiebaut -- Computer Science
Computer Science Dominique Thiebaut Who? Where? Why? • Ben Fry & Casey Reas • MIT Media Labs 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.
Computer Science Dominique Thiebaut Ben Fry on Processing... http://www.youtube.com/watch?&v=z-g-cWDnUdU
Computer Science Dominique Thiebaut An Example An Example • http://processing.org = GREAT RESOURCE! • Mouse 2D Examplehttp://processing.org/examples/mouse2d.html
Computer Science Dominique Thiebaut How does it Work?
Computer Science Dominique Thiebaut How does it Work? • Java • Java independent of operating system • Processing works on Windows, Mac, Linux
Computer Science Dominique Thiebaut Writing a Sketch
Computer Science Dominique Thiebaut Writing a Sketch • Functions • User functions • Library functions • Predefined: • setup() • draw() • mouseX • mouseY
Computer Science Dominique Thiebaut 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 LanguageExample 1 • void setup() { • int a = 10; • int b = 20; • int c = 0; • c = a+b; • println(“c= “ + c); • } Add two variables and store their sum into a third variable
Computer Science Dominique Thiebaut Example 2 • void setup() { • int count = 1; • while (true) { • println(count); • count = count+1; • } • } Write an infinite loop that prints all the positive integers.
Computer Science Dominique Thiebaut Example 2 • void setup() { • int count = 1; • while (true) { • println(count); • count = count+1; • } • } Write an infinite loop that prints all the positive integers.
Computer Science Dominique Thiebaut Example 2 • void setup() { • int count = 1; • while (true) { • println(count); • count = count+1; • } • } Write an infinite loop that prints all the positive integers.
Computer Science Dominique Thiebaut Example 3 • void setup() { • int count = 1; • while ( ) { • println(count); • count = count+1; • } • } Write an loop that prints all the integers from 1 to 10.
Computer Science Dominique Thiebaut Example 3 • void setup() { • int count = 1; • while (count<=10) { • println(count); • count = count+1; • } • } Write an loop that prints all the integers from 1 to 10.
Computer Science Dominique Thiebaut Example 4 • void setup() { • int count = 1; • int sum = 0; • while ( ) { • } • } Write an loop that computes the sum of all the integers from 1 to 10 and prints the result.
Computer Science Dominique Thiebaut Example 4 • void setup() { • int count = 1; • int sum = 0; • while (count<=10) { • sum = sum+count; • count = count+1; • } • println(“sum=”+sum); • } Write an loop that computes the sum of all the integers from 1 to 10 and prints the result.
Computer Science Dominique Thiebaut 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