Processing (Software)
Processing (Software)
Proce55ing
Processing è un ambiente e un
linguaggio di programmazione
basato su Java per creare prodotti
multimediali interattivi open source
Processing e gratuito per GNU/Linux, Mac OS
X, e Windows creato nel 2001 al
Lezione 01
MIT Media Lab.
https://www.processing.org
https://vimeo.com/3245120
“TheNestThatSailedTheSky”di PeterGabriel
Daniel Shiffman realizzato con Processing da Glenn Marshall
ketch_190224a
Menu
Toolbar
Tabs
Sketch
Code editor
Display Window
Message Area
IDE
integrated Console
development
Status bar
environment
Sistema di riferimento
sketch Posizionamento X,Y
Color
Colori, spessori
strokeWeight(10)
spessore linea o bordo
stroke(0, 0, 255)
colore linea o bordo in RGB (red,
green, blue) ogni canale va da
0-255.
Strumenti di
noStroke() disegno
non disegna la linea Rettangoli, linee e cerchi
fill(255, 0, 0)
colore del riempimento in RGB
noFill()
nessun riempimento
(x,y)
(x,y)
(x2,y2) (x3,y3)
Primitive point(x, y)
grafiche
(x2,y2) (x3,y3)
(x2,y2) (x2,y2) (x3,y3)
(x2,y2)
(x,y) void setup() {
quad(x1, y1, x2, y2, x3, y,
rect(x, y3,width,
x4, y4)
height) size(640, 480);
y2) 1. point()
triangle(x1,
(x,y) y1, x2, y2,
quad(x1, x3,
y1, y3)
x2, y2, x3, y3, x4, y4)
(x1,y1) (x4,y4)
(x1,y1)
line(x1, y1, x2,
(x1,y1) (x4,y4)
triangle(x1, y1, x2, y2, x3, y3) }point(x, y)
(x1,y1) (x1,y1) 2. line()
3. triangle()
height
(x,y) void draw() {
(x2,y2) (x3,y3)
(x2,y2) (x3,y3) (x2,y2) width
(x3,y3)
4. quad() strokeWeight(20);
(x2,y2) (x2,y2) (x3,y3)
5. rect() point(70, 100);
line(x1, y1, x2, y2)
6. ellipse()
rect(x, y, width,ellipse(x,
height) y, width, height)
(x1,y1) point(70, 150);
(x,y) quad(x1, y1, x2, rect(x,
y2, x3, y,
y3,width,
x4, y4)
height)
(x1,y1) (x4,y4) triangle(x1,
(x,y) y1, quad(x1,
x2, y2, x3,
y1, y3)
x2, y2, x3, y3, x4, y4) point(70, 200);
(x1,y1) (x1,y1)
(x,y) (x4,y4)
height
point(70, 250);
height
point(x, y)
height point(70, 300);
line(x1, y1, x2, y2)
(x1,y1) (x2,y2) }
(x2,y2)width
(x3,y3) width
(x2,y2) (x3,y3) (x2,y2)width
(x3,y3)
(x,y)
(x2,y2) (cx2,cy2)
width (x2,y2) (cx2,cy2) (x,y)
rect(x, y, width, height)
(x2,y2) (x3,y3) (x2,y2) (x3,y3)
ellipse(x, y, width, height) bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2)
(x2,y2) (x3,y3) (x1,y1) (cx1,cy1)
width
(x,y)
height
(x,y)
rect (x, y, width,
rect(x, height)height)
y, width, ellipse (x, y, width,
ellipse(x, height) height)
y, width,
width (x2,y2) (cx2,cy2)
void setup() { (x,y)
height
void setup() {
height
size(640, 480); size(640, 480);
bezier(x1,
} y1, cx1, cy1, cx2, cy2, x2, y2) }
(x1,y1) (cx1,cy1)
width void draw() { Geometry primitives
width
strokeWeight(5); void draw()
Processing has seven functions { in making simple shapes. These images s
to assist
noFill(); the parameters with numbersstrokeWeight(5);
to use them within a program. These functions are
ellipse(x,
stroke(0,0,0);y, width, height) bezier(x1, y1, 200,
ellipse(320, 240, cx1,200);
cy1, cx2, cy2, x2, y2)
(x1,y1) (cx1,cy1)
(x2,y2) (cx2,cy2) rect(10, 10, 40, 40); }
(x,y) stroke(255,0,0);
height
rect(60, 10, 40, 40);
fill(255,255,0);
Geometry primitives
width
rect(110, 10, 40, 40); (x2,y2) (cx2,cy2)
}
Processing has seven functions to assist in making simple shapes. These images show the format
Reas_01_001-084.indd for each. Replace
Sec2:28
the parameters with numbers to use them within a program. These functions are demonstrated in codes 2-04 to 2-22.
bezier(x1, y1, cx1, cy1, cx2, cy2, x2, y2)
(x1,y1) (cx1,cy1)
Geometry primitives
ordine
elementi
void setup() {
size(640, 480);
} Gli elementi grafici
vengono disegnati
nell’ordine con cui
Drawing modes
void draw() { sono scritti. ellipseMode(), rectMode()
rect(10,20,20,30); Questo condiziona la
rect(100,100,100,50); loro visualizzazione.
ellipse(100,100,50,50);
}
rectMode(RADIUS);
ellipseMode(RADIUS);
rectMode(CORNER);
ellipseMode(CORNER);
rectMode(CORNERS);
ellipseMode(CORNERS);
ellipseMode(RADIUS); rectMode(RADIUS);
fill(126); fill(126);
ellipse(33, 33, 60, 60); // Gray ellipse rect(33, 33, 60, 60); // Gray rect
fill(255); fill(255);
ellipseMode(CORNER); rectMode(CORNER);
ellipse(33, 33, 60, 60); // White ellipse rect(33, 33, 60, 60); // White rect
fill(0); fill(0);
ellipseMode(CORNERS); rectMode(CORNERS);
ellipse(33, 33, 60, 60); // Black ellipse rect(33, 33, 60, 60); // Black rect
Definizione di variabile
contenete un numero intero
Cicli int i = 0;
Loop e sequenze di
comandi
cicli For animazioni
void setup() { int i = 0;
size(640, 480);
} void setup() {
size(640, 480);
void draw() { rectMode(CENTER);
for (int i = 0; i < 400; i++) { }
rectMode(CENTER);
rect(i, i, 100, 100); void draw() {
} rect(i, i, 100, 100);
} i = i + 1;
}
esempi esempi
void setup() { void setup() {
size(640, 480); size(640, 480);
} }
void setup() {
size(480, 120);
}
void draw() {
Interazione ellipse(mouseX, mouseY, 80, 80);
mousePressed e mouse }
position
void setup() {
size(480, 120);
}
void draw() {
if (mousePressed) {
fill(0);
} else {
fill(255);
}
ellipse(mouseX, mouseY, 80, 80);
}