humano
June 1, 2022, 12:06am
1
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();
}
mnse
June 1, 2022, 7:10am
2
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
1 Like
mnse
June 1, 2022, 7:18am
3
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
1 Like
thank you so much, awesome!
1 Like