Mixing "active" & "static" modes.
in
Programming Questions
•
3 months ago
Hi, I can't figure out where is the mistake. Seen other similar errors, and checked if there's any misspelled code or missing semicolon or parenthesis and everything seems alright. Thanks for any light shed on the matter. (Exercise extracted from Pearson's Generative Art book)
size(500, 100);
background(255);
smooth();
stroke(0, 30);
line(20, 50, 480, 50);
float xstep = 1;
float lastx = -999;
float lasty = -999;
float angle = 0;
float y = 50;
for (int x=20; x<=480; x+=xstep) {
float rad = radians(angle);
// y = 50 + (sin(rad)*40);
// y = 50 + (pow(sin(rad), 3) * 45);
// y = 50 + (pow(sin(rad), 3) * noise(rad*2) * 30);
//personalizada –un poco–
y = 20 + (customRandom() * 60);
if (lastx > -999) {
stroke(20, 50, 70, 111);
strokeWeight(3);
line(x, y, lastx, lasty);
}
lastx = x;
lasty = y;
angle++;
noFill();
stroke(0, 29);
strokeWeight(.3);
ellipse(lastx, lasty, 12, 12);
//println(y);
}
//funcion personalizada de aleatoriedad
float customRandom() {
float retValue = 1 - pow(random(1), 5);
return retValue;
}
1