SlideShare una empresa de Scribd logo
1 de 32
Introduction to Processing
Kids & Technology Meetup
April 5, 2014
Washington, DC
Download and Install Processing
 Go to https://processing.org/download/
 Download
 Extract the files
 Processing can be run from any location, but on Windows it is conventional to
place the folder into C:Program Filesprocessing-2.1.1 (or whatever version)
 Instructions for Mac and Linux can be found here:
http://www.processing.org/tutorials/gettingstarted/
 Create a shortcut for the Processing.exe file and place on the Desktop
Processing Development Environment
(PDE)
Run program
Stop
Type code here
Remember to
save! (click on
“File”)
Code files in
Processing are
called “sketches”
The Canvas
 To control the size of the canvas, type: size(X, Y);
 X = width
 Y = height
 size(500, 250); creates the following:
Must end with ;
X
Y
(0, 0)
(500, 250)
(500, 0)
(0, 250)
Must be lower case
What are the X and
Y coordinates for a
point in the middle?
Let’s Code!
size(500, 500);
point(100, 100);
Press Run!
Canvas Layout
This is the X,Y coordinate
system we learn in school:
This is the coordinate system
for the Canvas. Each point is a
pixel:
Basic Shapes - Point
point(X, Y);
Point
point(4, 5);
Basic Shapes - Line
line(X1, Y1, X2, Y2);
Line
Starting
point
Ending
point
line(1, 2, 5, 2);
Basic Shapes - Rectangle
rect(X, Y, W, H);
Rectangle
Width
Height
Starting
point
Width
Height
rect(4, 5, 5, 3);
Basic Shapes - Ellipse
ellipse(X, Y, W, H);
Ellipse
Center
Width
Height
Height
Width
ellipse(4, 5, 3, 7);An ellipse where W = H
is a circle !
Draw a Figure
 Use what we have learned to combine shapes and draw something
 Or you can use the code below – make sure you understand what each line is doing
size(200,200);
rectMode(CENTER);
rect(100,100,20,100);
ellipse(100,70,60,60);
ellipse(81,70,16,32);
ellipse(119,70,16,32);
line(90,150,80,160);
line(110,150,120,160);
Source: http://processing.org/tutorials/drawing/
Add Some “Color”
Set the background color to white:
background(255);
Why do we use 255 for white?
Grayscale
stroke() and fill()
The line color (or outline color) is set with stroke();
Set the line color to black:
stroke(0);
Set the shape’s fill color to gray:
fill(150);
Numbers closer to 0 will be darker, closer to 255 will be lighter.
Now Let’s Really Add Some Color
RGB – Red Green Blue
Instead of typing fill(150), we can use
the three RGB values:
fill(R, G, B);
fill(255, 0, 0); // red
fill(0, 255, 0); // green
fill(0, 0, 255); // blue
fill(100, 50, 50); // to mix colors
Using Multiple Colors in One Sketch
 Every time you add the stroke() or fill() statements, the shapes that
follow will get those colors
 You can keep changing colors within a sketch, as shown here:
background(255);
size(500, 500);
// Bright red
fill(255,0,0);
ellipse(100,100,50,50);
// Dark red
fill(127,0,0);
ellipse(200,200,50,50);
// Blue
fill(100,100,255);
ellipse(300,300,50,50);
Find the Perfect Color
 Processing has a color selector tool
RGB values
Color Transparency
 To let portions of objects “beneath” other objects
show through, we an add transparency
fill(0, 255, 0, 255); // green, opaque
fill(255, 0, 0, 125); // red, about 50% transparent
0 = completely transparent
255 = completely opaque
The first object in the sketch will be on the bottom.
The next will go “above” that one. Each object is added to a new layer.
Examples
 File / Examples
How About Animation?
 Yes, you can do that in Processing
 But, we need to learn a few more things first
Variables
Loops
Conditionals
Variables
 Variables are used for storing values
 We can change those values if we want to
 For drawing, we are mostly going to use integers and decimal
numbers (floating point numbers)
int boxWidth = 75; // the box width is an integer and its value is 75 pixels
int boxHeight = 50;
float y = 2.5; // y is a decimal and its value is 2.5
We can change the values of variables in our code.
Other variable types are described here:
http://www.openobject.org/physicalprogramming/Using_Variables_in_Processing
Loops
 To make an object move, we will have to “loop” or repeat
some code many times
 Now we will use the Processing program structure
Loops – Processing Structure
Declare variables
setup() – these commands
are only done once
Loop – the draw() loop
repeats over and over
Notice that setup() and draw()
enclose their contents inside
curly braces.
Conditionals
 If this happens, then do that
if (test) {
then do something;
}
if (test) {
then do something;
}
else
{
do something else;
}
Within each block (between the curly braces), there can be
multiple lines of code.
Conditionals - continued
x = 0;
draw()
{
x = x + 1;
if (x > 100) {
x = 0;
}
}
Add one to x (increment x).
Check if x is greater than 100.
If so, set x back to 0.
Repeat that over and over.
Animation Example
 Let’s draw a box that moves across the screen
 First draw the box on the left side of the canvas
 Do this in setup()
int x; // declare x and y for our starting point
int y;
void setup() {
size(500, 500);
background(255);
stroke(255);
fill(100,100,255);
x = 0;
y = 150;
}
Animation Example - continued
 Now let’s think about our draw() loop
 Let’s start with a box on the left side of the screen
 How do we move the box toward the right hand side?
void draw() {
rect(x, y, 100, 75); // draw the box, use x & y for start location
x = x + 5; // increase x by 5 (you can try other values)
if (x > 500) { // if x is more the 500, it has passed the right side
x = 0; // set x back to zero so it goes back to the left
}
}
Animation Example - continued
 But there’s a problem!
 The box seems to be writing over itself, leaving a trail
 We need to erase the old box before we draw the new box
void draw() {
background(255); // redraw the background each time
rect(x, y, 100, 75);
x = x + 5;
if (x > 500) {
x = 0;
}
}
You can find the full code listing here http://green.mn/1hszuUZ
Animation Example 2 – add a twist
 Instead of the box moving to the right, then appearing back at the left hand
side after “dropping off” the right-hand side…
 Let’s make it “bounce” off of the left side of the canvas, then travel back to
the right and “bounce” off of the right side of the canvas, etc.
 Think about how you would do that…
Animation Example 2 – continued
 When the box touches the right-hand side of the canvas, instead of x = x + 5
we need to have x = x – 5
 One way to do this is to make the 5 value a variable
 Then we can change its sign
void draw() {
background(255);
rect(x, y, 100, 75);
x = x + step;
if (x == 400 || x == 0)
{
step = step * (-1);
}
}
// “step” variable
// if the rectangle touches either side
// reverse the sign of “step”
You can find the full code listing here http://green.mn/1gBdBCE
A Little More Advanced: Generative Art
 A program that draws something differently each time you run it
 Or it keeps drawing until you stop it
Source: Generative Art: A Practical Guide Using Processing, by Matt Pearson
Tutorials and Resources
 https://www.processing.org/reference/
 http://processing.org/tutorials/
 http://hello.processing.org/
 http://funprogramming.org/
 http://carrot.whitman.edu/IntroProcessing/syllabus.html
 http://sketchpad.cc
Questions?
 These slides will be posted on SlideShare and the link will be provided
 Contact me on Twitter: @JohnDukovich or @GreenMoonArt
 Follow this MeetUp: http://www.meetup.com/Kids-and-Technology/

Más contenido relacionado

La actualidad más candente

Σίνου Μάρθα_Σκούρτη_Άννα_Παρουσίαση_Σεναρίου_Φως_και_Σκιά
Σίνου Μάρθα_Σκούρτη_Άννα_Παρουσίαση_Σεναρίου_Φως_και_ΣκιάΣίνου Μάρθα_Σκούρτη_Άννα_Παρουσίαση_Σεναρίου_Φως_και_Σκιά
Σίνου Μάρθα_Σκούρτη_Άννα_Παρουσίαση_Σεναρίου_Φως_και_ΣκιάMarthaBoo
 
Ασκήσεις με πεδία της επικεφαλίδας ενός ΙΡ πακέτου
Ασκήσεις με πεδία της επικεφαλίδας ενός ΙΡ πακέτουΑσκήσεις με πεδία της επικεφαλίδας ενός ΙΡ πακέτου
Ασκήσεις με πεδία της επικεφαλίδας ενός ΙΡ πακέτουKaterina Drimili
 
HTML-CSS για αρχάριους :: Μάθημα 1ο
HTML-CSS για αρχάριους :: Μάθημα 1οHTML-CSS για αρχάριους :: Μάθημα 1ο
HTML-CSS για αρχάριους :: Μάθημα 1οDespina Kamilali
 
θεωρίες και μοντέλα επικοινωνίας
θεωρίες και μοντέλα επικοινωνίαςθεωρίες και μοντέλα επικοινωνίας
θεωρίες και μοντέλα επικοινωνίαςkokonagera
 
AI & Machine Learning - Γράβας Χρ.pptx
AI & Machine Learning - Γράβας Χρ.pptxAI & Machine Learning - Γράβας Χρ.pptx
AI & Machine Learning - Γράβας Χρ.pptxChristopherGravas
 
Bιωματικές ασκήσεις για δουλειά με την ομάδα
Bιωματικές ασκήσεις για δουλειά με την ομάδαBιωματικές ασκήσεις για δουλειά με την ομάδα
Bιωματικές ασκήσεις για δουλειά με την ομάδαMakis Triantafillidis
 
H ψηφιακή aφήγηση ως εργαλείο έκφρασης και δημιουργίας
H ψηφιακή aφήγηση ως εργαλείο έκφρασης και  δημιουργίαςH ψηφιακή aφήγηση ως εργαλείο έκφρασης και  δημιουργίας
H ψηφιακή aφήγηση ως εργαλείο έκφρασης και δημιουργίαςVera Vorylla
 
Scratch: Φύλλο Εργασίας 4
Scratch: Φύλλο Εργασίας 4Scratch: Φύλλο Εργασίας 4
Scratch: Φύλλο Εργασίας 4Penelope Markellou
 
Στατιστικές Κατανομές και Πιθανότητες. Θεωρία και παραδείγματα.
Στατιστικές Κατανομές και Πιθανότητες. Θεωρία και παραδείγματα.Στατιστικές Κατανομές και Πιθανότητες. Θεωρία και παραδείγματα.
Στατιστικές Κατανομές και Πιθανότητες. Θεωρία και παραδείγματα.stratos goumas
 
Σκουπίδια! Είναι όλα άχρηστα;
Σκουπίδια! Είναι όλα άχρηστα;Σκουπίδια! Είναι όλα άχρηστα;
Σκουπίδια! Είναι όλα άχρηστα;hrisgiou
 
Sygrouseis sto nipiagwgeio
Sygrouseis sto nipiagwgeioSygrouseis sto nipiagwgeio
Sygrouseis sto nipiagwgeiossuser04ff74
 
Κεφάλαιο 3 - Πολυμέσα
Κεφάλαιο 3 - ΠολυμέσαΚεφάλαιο 3 - Πολυμέσα
Κεφάλαιο 3 - Πολυμέσαomada11
 
Συναισθήματα και τέχνη ("παιχνίδι" για αναγνώριση και έκφραση συναισθημάτων)
Συναισθήματα και τέχνη ("παιχνίδι" για αναγνώριση και έκφραση συναισθημάτων)Συναισθήματα και τέχνη ("παιχνίδι" για αναγνώριση και έκφραση συναισθημάτων)
Συναισθήματα και τέχνη ("παιχνίδι" για αναγνώριση και έκφραση συναισθημάτων)Αντιγόνη Κριπαροπούλου
 
Να βελτιώσουμε τις παρουσιάσεις μας
Να βελτιώσουμε τις παρουσιάσεις μαςΝα βελτιώσουμε τις παρουσιάσεις μας
Να βελτιώσουμε τις παρουσιάσεις μαςTheresa Giakoumatou
 
σχεδιο μαθηματοσ φυλλο εργασιασ Power point
σχεδιο μαθηματοσ φυλλο εργασιασ Power pointσχεδιο μαθηματοσ φυλλο εργασιασ Power point
σχεδιο μαθηματοσ φυλλο εργασιασ Power pointthanslide
 
Φύλλο Εργασίας για Λογικές Εκφράσεις & Δομή Επιλογής
Φύλλο Εργασίας για Λογικές Εκφράσεις & Δομή ΕπιλογήςΦύλλο Εργασίας για Λογικές Εκφράσεις & Δομή Επιλογής
Φύλλο Εργασίας για Λογικές Εκφράσεις & Δομή Επιλογήςgeormak
 

La actualidad más candente (20)

Σίνου Μάρθα_Σκούρτη_Άννα_Παρουσίαση_Σεναρίου_Φως_και_Σκιά
Σίνου Μάρθα_Σκούρτη_Άννα_Παρουσίαση_Σεναρίου_Φως_και_ΣκιάΣίνου Μάρθα_Σκούρτη_Άννα_Παρουσίαση_Σεναρίου_Φως_και_Σκιά
Σίνου Μάρθα_Σκούρτη_Άννα_Παρουσίαση_Σεναρίου_Φως_και_Σκιά
 
Ασκήσεις με πεδία της επικεφαλίδας ενός ΙΡ πακέτου
Ασκήσεις με πεδία της επικεφαλίδας ενός ΙΡ πακέτουΑσκήσεις με πεδία της επικεφαλίδας ενός ΙΡ πακέτου
Ασκήσεις με πεδία της επικεφαλίδας ενός ΙΡ πακέτου
 
HTML-CSS για αρχάριους :: Μάθημα 1ο
HTML-CSS για αρχάριους :: Μάθημα 1οHTML-CSS για αρχάριους :: Μάθημα 1ο
HTML-CSS για αρχάριους :: Μάθημα 1ο
 
θεωρίες και μοντέλα επικοινωνίας
θεωρίες και μοντέλα επικοινωνίαςθεωρίες και μοντέλα επικοινωνίας
θεωρίες και μοντέλα επικοινωνίας
 
AI & Machine Learning - Γράβας Χρ.pptx
AI & Machine Learning - Γράβας Χρ.pptxAI & Machine Learning - Γράβας Χρ.pptx
AI & Machine Learning - Γράβας Χρ.pptx
 
Bιωματικές ασκήσεις για δουλειά με την ομάδα
Bιωματικές ασκήσεις για δουλειά με την ομάδαBιωματικές ασκήσεις για δουλειά με την ομάδα
Bιωματικές ασκήσεις για δουλειά με την ομάδα
 
H ψηφιακή aφήγηση ως εργαλείο έκφρασης και δημιουργίας
H ψηφιακή aφήγηση ως εργαλείο έκφρασης και  δημιουργίαςH ψηφιακή aφήγηση ως εργαλείο έκφρασης και  δημιουργίας
H ψηφιακή aφήγηση ως εργαλείο έκφρασης και δημιουργίας
 
Scratch: Φύλλο Εργασίας 4
Scratch: Φύλλο Εργασίας 4Scratch: Φύλλο Εργασίας 4
Scratch: Φύλλο Εργασίας 4
 
Στατιστικές Κατανομές και Πιθανότητες. Θεωρία και παραδείγματα.
Στατιστικές Κατανομές και Πιθανότητες. Θεωρία και παραδείγματα.Στατιστικές Κατανομές και Πιθανότητες. Θεωρία και παραδείγματα.
Στατιστικές Κατανομές και Πιθανότητες. Θεωρία και παραδείγματα.
 
ΚΩΔΙΚΟΠΟΙΗΣΗ
ΚΩΔΙΚΟΠΟΙΗΣΗΚΩΔΙΚΟΠΟΙΗΣΗ
ΚΩΔΙΚΟΠΟΙΗΣΗ
 
Σκουπίδια! Είναι όλα άχρηστα;
Σκουπίδια! Είναι όλα άχρηστα;Σκουπίδια! Είναι όλα άχρηστα;
Σκουπίδια! Είναι όλα άχρηστα;
 
Sygrouseis sto nipiagwgeio
Sygrouseis sto nipiagwgeioSygrouseis sto nipiagwgeio
Sygrouseis sto nipiagwgeio
 
Κεφάλαιο 3 - Πολυμέσα
Κεφάλαιο 3 - ΠολυμέσαΚεφάλαιο 3 - Πολυμέσα
Κεφάλαιο 3 - Πολυμέσα
 
To θεωρημα rolle
To θεωρημα rolleTo θεωρημα rolle
To θεωρημα rolle
 
Συναισθήματα και τέχνη ("παιχνίδι" για αναγνώριση και έκφραση συναισθημάτων)
Συναισθήματα και τέχνη ("παιχνίδι" για αναγνώριση και έκφραση συναισθημάτων)Συναισθήματα και τέχνη ("παιχνίδι" για αναγνώριση και έκφραση συναισθημάτων)
Συναισθήματα και τέχνη ("παιχνίδι" για αναγνώριση και έκφραση συναισθημάτων)
 
Να βελτιώσουμε τις παρουσιάσεις μας
Να βελτιώσουμε τις παρουσιάσεις μαςΝα βελτιώσουμε τις παρουσιάσεις μας
Να βελτιώσουμε τις παρουσιάσεις μας
 
Diadrastikoi b senaria
Diadrastikoi b senariaDiadrastikoi b senaria
Diadrastikoi b senaria
 
σχεδιο μαθηματοσ φυλλο εργασιασ Power point
σχεδιο μαθηματοσ φυλλο εργασιασ Power pointσχεδιο μαθηματοσ φυλλο εργασιασ Power point
σχεδιο μαθηματοσ φυλλο εργασιασ Power point
 
Φύλλο Εργασίας για Λογικές Εκφράσεις & Δομή Επιλογής
Φύλλο Εργασίας για Λογικές Εκφράσεις & Δομή ΕπιλογήςΦύλλο Εργασίας για Λογικές Εκφράσεις & Δομή Επιλογής
Φύλλο Εργασίας για Λογικές Εκφράσεις & Δομή Επιλογής
 
πολυμέσα β γυμνασιου
πολυμέσα β γυμνασιουπολυμέσα β γυμνασιου
πολυμέσα β γυμνασιου
 

Destacado

Introduction to digital image processing
Introduction to digital image processingIntroduction to digital image processing
Introduction to digital image processingHossain Md Shakhawat
 
LinkedIn Learning | What We're Learning About Learning
LinkedIn Learning | What We're Learning About LearningLinkedIn Learning | What We're Learning About Learning
LinkedIn Learning | What We're Learning About LearningLinkedIn Learning Solutions
 
Arduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoArduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoEoin Brazil
 
Arduino Full Tutorial
Arduino Full TutorialArduino Full Tutorial
Arduino Full TutorialAkshay Sharma
 
An Introduction to Processing
An Introduction to ProcessingAn Introduction to Processing
An Introduction to ProcessingCate Huston
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShareSlideShare
 
What to Upload to SlideShare
What to Upload to SlideShareWhat to Upload to SlideShare
What to Upload to SlideShareSlideShare
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShareSlideShare
 

Destacado (9)

Introduction to Arduino
Introduction to ArduinoIntroduction to Arduino
Introduction to Arduino
 
Introduction to digital image processing
Introduction to digital image processingIntroduction to digital image processing
Introduction to digital image processing
 
LinkedIn Learning | What We're Learning About Learning
LinkedIn Learning | What We're Learning About LearningLinkedIn Learning | What We're Learning About Learning
LinkedIn Learning | What We're Learning About Learning
 
Arduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the ArduinoArduino Lecture 1 - Introducing the Arduino
Arduino Lecture 1 - Introducing the Arduino
 
Arduino Full Tutorial
Arduino Full TutorialArduino Full Tutorial
Arduino Full Tutorial
 
An Introduction to Processing
An Introduction to ProcessingAn Introduction to Processing
An Introduction to Processing
 
2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare2015 Upload Campaigns Calendar - SlideShare
2015 Upload Campaigns Calendar - SlideShare
 
What to Upload to SlideShare
What to Upload to SlideShareWhat to Upload to SlideShare
What to Upload to SlideShare
 
Getting Started With SlideShare
Getting Started With SlideShareGetting Started With SlideShare
Getting Started With SlideShare
 

Similar a Introduction to Processing

Introduction to programming - class 3
Introduction to programming - class 3Introduction to programming - class 3
Introduction to programming - class 3Paul Brebner
 
Interactive Mouse (Report On Processing)
Interactive Mouse (Report On Processing)Interactive Mouse (Report On Processing)
Interactive Mouse (Report On Processing)TongXu520
 
Learn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageLearn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageW M Harris
 
Learn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageLearn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing Languageshelfrog
 
Introduction to Generative Art with Processing
Introduction to Generative Art with ProcessingIntroduction to Generative Art with Processing
Introduction to Generative Art with Processingstefk00
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bPhilip Schwarz
 
Processing Workshop Slides for Ladies Learning Code - March 22, 2014
Processing Workshop Slides for Ladies Learning Code - March 22, 2014Processing Workshop Slides for Ladies Learning Code - March 22, 2014
Processing Workshop Slides for Ladies Learning Code - March 22, 2014Stephen Boyd
 
More instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxMore instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxgilpinleeanna
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
Fp in scala part 2
Fp in scala part 2Fp in scala part 2
Fp in scala part 2Hang Zhao
 
The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202Mahmoud Samir Fayed
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxagnesdcarey33086
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to CodingFabio506452
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)yap_raiza
 
The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 179 of 185
The Ring programming language version 1.5.4 book - Part 179 of 185The Ring programming language version 1.5.4 book - Part 179 of 185
The Ring programming language version 1.5.4 book - Part 179 of 185Mahmoud Samir Fayed
 
[EN] Ada Lovelace Day 2014 - Tampon run
[EN] Ada Lovelace Day 2014  - Tampon run[EN] Ada Lovelace Day 2014  - Tampon run
[EN] Ada Lovelace Day 2014 - Tampon runMaja Kraljič
 

Similar a Introduction to Processing (20)

Introduction to programming - class 3
Introduction to programming - class 3Introduction to programming - class 3
Introduction to programming - class 3
 
Interactive Mouse (Report On Processing)
Interactive Mouse (Report On Processing)Interactive Mouse (Report On Processing)
Interactive Mouse (Report On Processing)
 
Learn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageLearn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing Language
 
Learn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing LanguageLearn Creative Coding: Begin Programming with the Processing Language
Learn Creative Coding: Begin Programming with the Processing Language
 
Introduction to Generative Art with Processing
Introduction to Generative Art with ProcessingIntroduction to Generative Art with Processing
Introduction to Generative Art with Processing
 
Computer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1bComputer Graphics in Java and Scala - Part 1b
Computer Graphics in Java and Scala - Part 1b
 
Processing Workshop Slides for Ladies Learning Code - March 22, 2014
Processing Workshop Slides for Ladies Learning Code - March 22, 2014Processing Workshop Slides for Ladies Learning Code - March 22, 2014
Processing Workshop Slides for Ladies Learning Code - March 22, 2014
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
More instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docxMore instructions for the lab write-up1) You are not obli.docx
More instructions for the lab write-up1) You are not obli.docx
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
Fp in scala part 2
Fp in scala part 2Fp in scala part 2
Fp in scala part 2
 
The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202The Ring programming language version 1.8 book - Part 94 of 202
The Ring programming language version 1.8 book - Part 94 of 202
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
Introduction to Coding
Introduction to CodingIntroduction to Coding
Introduction to Coding
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84
 
The Ring programming language version 1.5.4 book - Part 179 of 185
The Ring programming language version 1.5.4 book - Part 179 of 185The Ring programming language version 1.5.4 book - Part 179 of 185
The Ring programming language version 1.5.4 book - Part 179 of 185
 
[EN] Ada Lovelace Day 2014 - Tampon run
[EN] Ada Lovelace Day 2014  - Tampon run[EN] Ada Lovelace Day 2014  - Tampon run
[EN] Ada Lovelace Day 2014 - Tampon run
 
P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218P5js syracuse dev meetup 20181218
P5js syracuse dev meetup 20181218
 

Último

Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 

Último (20)

Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 

Introduction to Processing

  • 1. Introduction to Processing Kids & Technology Meetup April 5, 2014 Washington, DC
  • 2. Download and Install Processing  Go to https://processing.org/download/  Download  Extract the files  Processing can be run from any location, but on Windows it is conventional to place the folder into C:Program Filesprocessing-2.1.1 (or whatever version)  Instructions for Mac and Linux can be found here: http://www.processing.org/tutorials/gettingstarted/  Create a shortcut for the Processing.exe file and place on the Desktop
  • 3. Processing Development Environment (PDE) Run program Stop Type code here Remember to save! (click on “File”) Code files in Processing are called “sketches”
  • 4. The Canvas  To control the size of the canvas, type: size(X, Y);  X = width  Y = height  size(500, 250); creates the following: Must end with ; X Y (0, 0) (500, 250) (500, 0) (0, 250) Must be lower case What are the X and Y coordinates for a point in the middle?
  • 6. Canvas Layout This is the X,Y coordinate system we learn in school: This is the coordinate system for the Canvas. Each point is a pixel:
  • 7. Basic Shapes - Point point(X, Y); Point point(4, 5);
  • 8. Basic Shapes - Line line(X1, Y1, X2, Y2); Line Starting point Ending point line(1, 2, 5, 2);
  • 9. Basic Shapes - Rectangle rect(X, Y, W, H); Rectangle Width Height Starting point Width Height rect(4, 5, 5, 3);
  • 10. Basic Shapes - Ellipse ellipse(X, Y, W, H); Ellipse Center Width Height Height Width ellipse(4, 5, 3, 7);An ellipse where W = H is a circle !
  • 11. Draw a Figure  Use what we have learned to combine shapes and draw something  Or you can use the code below – make sure you understand what each line is doing size(200,200); rectMode(CENTER); rect(100,100,20,100); ellipse(100,70,60,60); ellipse(81,70,16,32); ellipse(119,70,16,32); line(90,150,80,160); line(110,150,120,160); Source: http://processing.org/tutorials/drawing/
  • 12. Add Some “Color” Set the background color to white: background(255); Why do we use 255 for white? Grayscale
  • 13. stroke() and fill() The line color (or outline color) is set with stroke(); Set the line color to black: stroke(0); Set the shape’s fill color to gray: fill(150); Numbers closer to 0 will be darker, closer to 255 will be lighter.
  • 14. Now Let’s Really Add Some Color RGB – Red Green Blue Instead of typing fill(150), we can use the three RGB values: fill(R, G, B); fill(255, 0, 0); // red fill(0, 255, 0); // green fill(0, 0, 255); // blue fill(100, 50, 50); // to mix colors
  • 15. Using Multiple Colors in One Sketch  Every time you add the stroke() or fill() statements, the shapes that follow will get those colors  You can keep changing colors within a sketch, as shown here: background(255); size(500, 500); // Bright red fill(255,0,0); ellipse(100,100,50,50); // Dark red fill(127,0,0); ellipse(200,200,50,50); // Blue fill(100,100,255); ellipse(300,300,50,50);
  • 16. Find the Perfect Color  Processing has a color selector tool RGB values
  • 17. Color Transparency  To let portions of objects “beneath” other objects show through, we an add transparency fill(0, 255, 0, 255); // green, opaque fill(255, 0, 0, 125); // red, about 50% transparent 0 = completely transparent 255 = completely opaque The first object in the sketch will be on the bottom. The next will go “above” that one. Each object is added to a new layer.
  • 19. How About Animation?  Yes, you can do that in Processing  But, we need to learn a few more things first Variables Loops Conditionals
  • 20. Variables  Variables are used for storing values  We can change those values if we want to  For drawing, we are mostly going to use integers and decimal numbers (floating point numbers) int boxWidth = 75; // the box width is an integer and its value is 75 pixels int boxHeight = 50; float y = 2.5; // y is a decimal and its value is 2.5 We can change the values of variables in our code. Other variable types are described here: http://www.openobject.org/physicalprogramming/Using_Variables_in_Processing
  • 21. Loops  To make an object move, we will have to “loop” or repeat some code many times  Now we will use the Processing program structure
  • 22. Loops – Processing Structure Declare variables setup() – these commands are only done once Loop – the draw() loop repeats over and over Notice that setup() and draw() enclose their contents inside curly braces.
  • 23. Conditionals  If this happens, then do that if (test) { then do something; } if (test) { then do something; } else { do something else; } Within each block (between the curly braces), there can be multiple lines of code.
  • 24. Conditionals - continued x = 0; draw() { x = x + 1; if (x > 100) { x = 0; } } Add one to x (increment x). Check if x is greater than 100. If so, set x back to 0. Repeat that over and over.
  • 25. Animation Example  Let’s draw a box that moves across the screen  First draw the box on the left side of the canvas  Do this in setup() int x; // declare x and y for our starting point int y; void setup() { size(500, 500); background(255); stroke(255); fill(100,100,255); x = 0; y = 150; }
  • 26. Animation Example - continued  Now let’s think about our draw() loop  Let’s start with a box on the left side of the screen  How do we move the box toward the right hand side? void draw() { rect(x, y, 100, 75); // draw the box, use x & y for start location x = x + 5; // increase x by 5 (you can try other values) if (x > 500) { // if x is more the 500, it has passed the right side x = 0; // set x back to zero so it goes back to the left } }
  • 27. Animation Example - continued  But there’s a problem!  The box seems to be writing over itself, leaving a trail  We need to erase the old box before we draw the new box void draw() { background(255); // redraw the background each time rect(x, y, 100, 75); x = x + 5; if (x > 500) { x = 0; } } You can find the full code listing here http://green.mn/1hszuUZ
  • 28. Animation Example 2 – add a twist  Instead of the box moving to the right, then appearing back at the left hand side after “dropping off” the right-hand side…  Let’s make it “bounce” off of the left side of the canvas, then travel back to the right and “bounce” off of the right side of the canvas, etc.  Think about how you would do that…
  • 29. Animation Example 2 – continued  When the box touches the right-hand side of the canvas, instead of x = x + 5 we need to have x = x – 5  One way to do this is to make the 5 value a variable  Then we can change its sign void draw() { background(255); rect(x, y, 100, 75); x = x + step; if (x == 400 || x == 0) { step = step * (-1); } } // “step” variable // if the rectangle touches either side // reverse the sign of “step” You can find the full code listing here http://green.mn/1gBdBCE
  • 30. A Little More Advanced: Generative Art  A program that draws something differently each time you run it  Or it keeps drawing until you stop it Source: Generative Art: A Practical Guide Using Processing, by Matt Pearson
  • 31. Tutorials and Resources  https://www.processing.org/reference/  http://processing.org/tutorials/  http://hello.processing.org/  http://funprogramming.org/  http://carrot.whitman.edu/IntroProcessing/syllabus.html  http://sketchpad.cc
  • 32. Questions?  These slides will be posted on SlideShare and the link will be provided  Contact me on Twitter: @JohnDukovich or @GreenMoonArt  Follow this MeetUp: http://www.meetup.com/Kids-and-Technology/