void setup() { size(400, 300); } void draw() { background(200, 255, 200); stroke(0); rect(100, 40, 30, 30); rectbis(150, 40, 30, 30); rectter(250, 40, 30, 30); rectquad(300, 40, 30, 30); } void rectbis(int x, int y, int l, int L) { quad(x, y, x+l, y, x+l, y+L, x, y+L); } void rectter(int x, int y, int l, int L) { line(x, y, x+l, y); // ligne haut line(x+l, y, x+l, y+L); // ligne droite line(x+l, y+L, x, y+L); // ligne bas line(x, y+L, x, y); // ligne gauche // bonus remplissage pour avoir l'interieur blanc int i; for (i = x+1; i < x+l; i++){ stroke(255); line(i, y+1, i, y+L -1); } } void rectquad(int x, int y, int l, int L) { int i, j; for(i = x+1; i < x+l; i++){ for(j = y + 1; j < y+L; j++){ stroke(255); point(i, j); // point à l'interieur } stroke(0); point(i, y); // contour haut point(i, y+L); // contour bas } for(i = 0; i < L+1; i++){ stroke(0); point(x,y+i); // contour gauche point(x+l, y+i);// contour droit } }