Skip to content

Instantly share code, notes, and snippets.

@KrabCode
Created January 16, 2018 08:46
Show Gist options
  • Select an option

  • Save KrabCode/8ae7b29e0a2cc07f5b7874d2270e8e04 to your computer and use it in GitHub Desktop.

Select an option

Save KrabCode/8ae7b29e0a2cc07f5b7874d2270e8e04 to your computer and use it in GitHub Desktop.
recursively smaller lines!
void setup(){
//size(800,600);
fullScreen(P2D);
}
float step ;
void draw(){
background(255);
step = map(mouseX, 0, width, .1f, 1f);
drawRecursively(width/2, height/2, width/3, true);
}
void drawRecursively(float x, float y, float size, boolean hor){
if(size < width/2 && size > 2f){
if(hor){
line(x-size, y, x+size, y);
drawRecursively(x-size, y, size * step, !hor);
drawRecursively(x+size, y, size * step, !hor);
}else{
line(x, y-size, x, y+size);
drawRecursively(x, y-size, size * step, !hor);
drawRecursively(x, y+size, size * step, !hor);
}
}
}
@KrabCode
Copy link
Author

recursive_lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment