mmm...
first of all: you can call smooth() once at the start of your program. there's no need to call it each time you want to draw something.
i won't give you any examples - you can find many good ones in the Learning section - but maybe a good advice :
try thinking of your 'simple forms' as simple objects which all have similar properties and some differences. for example, your rectangles have similar properties (4 corners, the same way to draw them, etc.) and differences (i.e. where you used random fonctions : their position on the screen, size, etc.).
so let's reshape your code to take advantage of object-oriented programming :
Code:
// all simple objects will have the same structure :
class SimpleObject {
// parameters : position (x, y) and size (s)
int x, y, s;
// constructor method
SimpleObject(int _x, int _y, int _s) {
x = _x; y = _y; s = _s;
}
// drawing method
void draw() {
pushMatrix();
translate(x, y);
rect(0, 0, s, s);
popMatrix();
}
}
size(500, 500);
background(255);
rectMode(CENTER);
smooth();
for (int i = 0; i < 20; i++) {
SimpleObject s = new SimpleObject((int)random(width-10), (int)random(height-10), 10+(int)random(10));
s.draw();
}
then, by adding parameters and changing the drawing method you can get more complex shapes. for example, try this :
Code:
// drawing method
void draw() {
pushMatrix();
translate(x, y);
rect(0, 0, s, s);
rotate(PI/4);
rect(0, 0, s, s);
popMatrix();
}
have fun!