Vertici

beginShape()

L’utilizzo delle funzioni beginShape() e endShape() permette di creare forme più complesse.
Con beginShape() inizia la registrazione dei vertici per una figura e con endShape() finisce la registrazione.
Il valore del parametro MODE specifica quale tipo di figura creare con i vertici specificati.
I parametri disponibili per beginShape() sono POINTSLINESTRIANGLESTRIANGLE_FAN,TRIANGLE_STRIPQUADS e QUAD_STRIP.
Dopo la chiamata della funzione beginShape() devono seguire un certo numero di comandi vertex().
Per terminare la fase di disegno della figura si chiama endShape().
La funzione vertex() con due parametri specifica una posizione in 2D e la funzione vertex() con tre parametri specifica una posizione in 3D.
Ogni figura verrà tracciata con colore e riempimento corrispondenti a stroke() e fill() correnti.
Le trasformazioni come translate(), rotate() e scale() non funzionano all’interno di beginShape().
Analogamente non è possibile utilizzare altre figure come ellipse() o rect().
The P2D, P3D, and OPENGL renderer settings allow stroke() and fill() settings to be altered per-vertex, however the default JAVA2D renderer does not.
Settings such as strokeWeight(), strokeCap(), and strokeJoin() cannot be changed while inside a beginShape()/endShape() block with any renderer.

Sintassi

beginShape()
beginShape(MODE)

Parametri

MODEPOINTSLINESTRIANGLESTRIANGLE_FANTRIANGLE_STRIPQUADSQUAD_STRIP

endShape()

La funzione endShape() è la compagna di beginShape() e può essere chiamata solo dopo beginShape().
Quando si chiama endShape() tutte le informazioni sulle immagini successive alla precedente chiamata dibeginShape() sono scritte nel buffer video.
La costante CLOSE è il valore per il parametro MODE e chiude la fase disegno.

Sintassi

endShape()
endShape(MODE)

Parametri

MODE, si usa CLOSE come fine del disegno.

vertex()

Tutte le figure si costruiscono connettendo una serie di vertici.
vertex() è utilizzata per specificare le coordinate dei vertici di punti, linee, triangoli, quadrilateri, e poligoni e si utilizza esclusivamente tra le due funzioni beginShape() e endShape().
Per disegnare un vertice in 3D utilizzando il parametro z è necessario utilizzare il parametro P3D oppure OPENGL in combinazione con size().
This function is also used to map a texture onto the geometry.
The texture() function declares the texture to apply to the geometry and the u and v coordinates set define the mapping of this texture to the form.
By default, the coordinates used for u and v are specified in relation to the image’s size in pixels, but this relation can be changed with textureMode().

Sintassi

vertex(x, y); 
vertex(x, y, z); 
vertex(x, y, u, v); 
vertex(x, y, z, u, v);

Parametri

x,
y,
z, int / float: coordinate xyz del vertice
u,
v, int / float: coordinate orizzontale, verticale per il texture mapping

bezierVertex()
curveVertex()

texture()
textureMode()