Loop with function

Howdy! I am trying to do a loop with these lines that I have created on function “brush” but I only can draw it once. Could you please tell me how repeat this line with a loop?

void setup(){
size(1000,1000);
background(255,255,0);
noStroke();
}

void draw(){
//  for (int j =0; j<1000; j++) {
  brush(0,0);
}
//}

void brush(int x, int y){
strokeWeight(20);
colorMode(HSB, 360,100,100,1000);
for (int i = 0; i < 1000; i++) {
    stroke(360,100,100,800-i);
    point(i,0);
  }
  noLoop();
} 

Hi @humano,

what about this approach …

void draw(){
  background(255,255,0);
  strokeWeight(20);
  colorMode(HSB, 360,100,100,width);

  for (int j=1; j <= 10; j++) {
    brush(0,j*25,width/j);
  }
}

void brush(int x, int y, int len){
for (int i = 0; i < len; i++) {
    stroke(360,100,100,(len*0.8)-i);
    point(i,y);
  }
} 

Cheers
— mnse

dummy4

1 Like

Or slightly modified to encapsulate and use also x coordinate…

void draw(){
  background(255,255,0);
  for (int j=1; j <= 10; j++) {
    brush(j*5,j*25,width/j);
  }
}

void brush(int x, int y, int len){
  pushStyle();
  colorMode(HSB, 360,100,100,len);
  strokeWeight(20);  
  for (int i = 0; i < len; i++) {
    stroke(360,100,100,len-i);
    point(x+i,y);
  }
  popStyle();
} 

Cheers
— mnse

dummy5

1 Like

thank you so much, awesome!

1 Like