hi,
i'm sorry to post a question from my personal dumbness,
but i MUST understand a code from Ira's book.
He mentioned that "take your time to understand this code" in his book and kindly included no explanation at all.
i definitely took my time but it gets more and more confusing.
what i don't understand is the logic.
i can't find any logic in this code.
the logic with makes "auto-layout".
all i can see is just some values set by someone who knows the logic very well.
but i can't see that logic because i don't know.
i know that you guys have not much time to explain line by line about such a basic code, but i think it's very important to me to get an answer so that next time i have a problem, i can imitate the way of reading code of that angel-person who will answer for me.
thank you very much,
please help me.
here's the code. (i removed the part that does stroke cap style, to simplify a bit.)
Quote:
/*
Auto Layout
Ira Greenberg, November 21, 2005
*/
size(500, 300);
background(255);
strokeWeight(2);
int shapes = 10;
//padding value determines size and distances between the forms
int padding = 200;
float w = (width-padding)/shapes;
float h = w;
float colSpan = (width-shapes*w)/(shapes+1);
float x = colSpan;
float y = height/2-h/2;
for (int i=0; i<shapes; i++){
line(x, y, x+w, y);
line(x+w, y, x+w, y+h);
line(x, y+h, x+w, y+h);
line(x, y+h, x, y);
x+=w+colSpan;
}
'sorry for my english..