This is supposed to produce vertical lines of varying colors and lengths and I can only get it to produce lines of the same color and length. I have looked at it over and over and I can’t figure out what I am doing wrong.
float randomZ;
void setup()
{
size(400,400);
background(250,250,0);
}
void draw()
{
strokeWeight(3);
stroke(random(0,85), random(86,170), random(171,256));
int x=0;
int y=0;
randomZ=random(50,width);
for(x=0; x<=width; x+=20){
for(randomZ=50; randomZ<height; randomZ++){
line(x,y,x,randomZ);
}
}
}
2 Likes
float randomZ;
void setup() {
size(400, 400);
background(250, 250, 0);
frameRate(4);
}
void draw() {
background(250, 250, 0);
strokeWeight(3);
stroke(random(0, 85), random(86, 170), random(171, 256));
int x=0;
int y=0;
for (x=0; x<=width; x+=20) {
randomZ=random(50, width);
// for (randomZ=50; randomZ<height; randomZ++) {
line(x, y, x, randomZ);
// }
}
}
1 Like
This is just a rough fixing of the code, but if move fill && randomZ to the for loop you get different colors & then you also need background in draw too. Try this out to see if like.
float randomZ;
void setup()
{
size(400,400);
}
void draw(){
background(0);
strokeWeight(3);
int x=0;
int y=0;
for(x=0; x<=width; x+=20){
randomZ=random(50,width);
stroke(random(0,86), random(86,255), random(0,255));
line(x,y,x,randomZ);
}
}
1 Like
Thank you so much! I really appreciate your help.
1 Like
Thank you so much! I really appreciate your help!