Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
              
            
!

CSS

              
                body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000028;
}
              
            
!

JS

              
                //yeah - this is a mess. I'd like to say that I'd clean it up, but I wont. no comments, código muito confuso - just mess. stream of conciousness tile work.
//#wccchallenge

//click to change, arrows do stuff too

//código muito confuso
let n = 10;
let d = 0;
let a1,a2,a3,a4;
let npattern = 14
let p = 14
function setup(){
  c = 600
  cnv = createCanvas(c,c);
  background(255)
  d = c/n
  c1 = color(0,90,140)
  c2 = color(0,0,40)
  c3 = color(50,150,200)
  c4 = color(0,40,60)
  colors1 = [c1,c2,c3,c4]
  noLoop()
  a1 = int(random(5,10))
  a2 = int(random(5,10))
  a3 = floor(random(0,3.99))
  a4 = floor(random(0,3.99))//border random
  r = d/2
  angleMode(DEGREES)
}
function draw(){
  translate(c/2,c/2);
  //p = floor(random(0,npattern+0.999))
  patterns(p)
  borders(3)
  lines()
}
function lines(){
  wcirc = random(10,45)
    grout = map(wcirc,10,45,0,2)
  for(let i = 0;i<=n;i++){
    stroke(255)
    fill(255)
    
    for(let j = -c/2;j<c/2;j++){
      circle(-c/2+i*d,j,wcirc/n-random(-grout,grout))
      circle(j,-c/2+i*d,wcirc/n-random(-grout,grout))
    }
   
  }
  for(let i = 0;i<=n;i++){
   stroke(c2)
    strokeWeight(20/n)
    line(-c/2+i*d,-c/2,-c/2+i*d,c/2)
    line(-c/2,-c/2+i*d,c/2,-c/2+i*d)
  }
}
function borders(b){
  
  if(b===0){
    fill(colors1[a3])
    stroke(colors1[a3])
    for(let i = 0;i<=n+1;i++){
      for(let j = 0;j<=n+1;j++){
        strokeWeight(18/a1)
        
        push()
        translate(-c/2 +i*d -d/2,-c/2 +j*d -d/2)
     push()
        triangle(-d/2,-d/2,-d/2+d/3,-d/2,-d/2,-d/2+d/3)
        triangle(d/2,d/2,d/2-d/3,d/2,d/2,d/2-d/3)
        triangle(d/2,-d/2,d/2-d/3,-d/2,d/2,-d/2+d/3)
        triangle(-d/2,d/2,-d/2+d/3,d/2,-d/2,d/2-d/3)
        pop()
        pop()
      }
    }
  }
  if(b===1){
    fill(colors1[a3])
    stroke(colors1[a3])
    for(let i = 0;i<=n+1;i++){
      for(let j = 0;j<=n+1;j++){
        strokeWeight(18/a1)
        
        push()
        translate(-c/2 +i*d -d/2,-c/2 +j*d -d/2)
     push()
        triangle(-d/2,-d/2,-d/2+d/2,-d/2,-d/2,-d/2+d/4)
        triangle(d/2,d/2,d/2-d/2,d/2,d/2,d/2-d/4)
        triangle(d/2,-d/2,d/2-d/2,-d/2,d/2,-d/2+d/4)
        triangle(-d/2,d/2,-d/2+d/2,d/2,-d/2,d/2-d/4)
        pop()
        pop()
      }
    }
  }
  if(b===2){
    fill(colors1[a3])
    stroke(colors1[a3])
    for(let i = 0;i<=n+1;i++){
      for(let j = 0;j<=n+1;j++){
        strokeWeight(18/a1)
        
        push()
        translate(-c/2 +i*d -d/2,-c/2 +j*d )
        arc(0,0,d,d/4,0,180)
        arc(0,0,d,d/4,180,360)
        translate(-d/2,-d/2)
        arc(0,0,d/4,d,0,180)
        arc(0,0,d/4,d,180,360)
        pop()
      }
    }
  }
}
function patterns(p){//pattern type
  if (p ===0){
    noFill()
    stroke(c1)
    for(let i = 0;i<=n;i++){
      for(let j = 0;j<=n;j++){
        strokeWeight(18/a1)
        for(let k = 0;k<a1/2;k++){
          circle(-c/2 + d*i,-c/2 + d*j,d/7*k)
          circle(-c/2 + d*i-d/2,-c/2 + d*j-d/2,d/7*k)
        } 
      }
    }
    
  }
  if (p ===1){
    r = d/2
    noFill()
    stroke(c1)
    for(let i = 0;i<=n;i++){
      for(let j = 0;j<=n;j++){
        strokeWeight(10/a1)
        for(let k = 0;k<int(a1/1.5);k++){
          if (i%2===0){
            
            push()
            translate(-c/2 + d*i-d/4,-c/2 + d*j-d/4)
            rotate(45)
            fill(c1)
            leafA()
            pop()
            push()
            translate(-c/2 + d*i-d/4,-c/2 + d*j+d/4)
            rotate(-45)
            fill(c1)
            leafA()
            pop()
            push()
            translate(-c/2 + d*i-2*d/3,-c/2 + d*j+d/2)
            rotate(-45)
            fill(c1)
            noFill()
            strokeWeight(d/20)
            spiral1()
            pop()
            
          }else{
            push()
            translate(-c/2 + d*i-3*d/4,-c/2 + d*j-d/4)
            rotate(-45)
            fill(c1)
            leafA()
            pop()
            push()
            translate(-c/2 + d*i-3*d/4,-c/2 + d*j+d/4)
            rotate(45)
            fill(c1)
            leafA()
            pop()
            push()
            translate(-c/2 + d*i-d/3,-c/2 + d*j+d/2)
            rotate(-225)
            noFill()
            strokeWeight(d/20)
            spiral1()
            pop()
          }
          
        } 
      }
    }
    borders(a1)
  }
  if (p ===2){
    noFill()
    stroke(c1)
    for(let i = 0;i<=n;i++){
      for(let j = 0;j<=n;j++){
        strokeWeight(18/a1)
        
        push()
        translate(-c/2 +i*d -d/2,-c/2 +j*d -d/2)
        fill(c4)
        stroke(c4)
        circle(0,0,d/9)
       
        if(i%2===0){
          signm = -1
        }else{
          signm = 1
        }
        for(let h = 0;h<a2;h++){
          r = d/5
          stroke(c1)
          fill(c1)
          push()
          rotate(360/a2*h)
          translate(d/5,0)
          rotate(45*signm)
          leafA()
          pop()
          push()
          rotate(360/a2*h)
          translate(d/2.9,0)
          rotate(45*signm)
          leafA()
          pop()
        }
        pop()
        
      }
    }
    borders(a4)
  }
  if (p ===3){
    for(let i = 0;i<=n;i++){
      for(let j = 0;j<=n;j++){
        strokeWeight(18/a1)
        
        push()
        translate(-c/2 +i*d -d/2,-c/2 +j*d -d/2)
        fill(c4)
        stroke(c4)
        circle(0,0,d/20)
       
        if(i%2===0){
          signm = -1
        }else{
          signm = 1
        }
        tmp1 = a1+4
        for(let h = 0;h<tmp1;h++){
          r = d/4
          stroke(colors1[a3])
          fill(colors1[a3])
          strokeWeight(d/40)
          push()
          rotate(360/tmp1*h)
          translate(d/5,0)
          rotate(60)
          leafC()
          pop()
          push()
          rotate(360/tmp1*h)
          translate(d/2.9,0)
          rotate(90)
          leafC()
          pop()
        }
        pop()
        
      }
    }
    borders(a4)
  }
  if (p ===4){
    for(let i = 0;i<=n;i++){
      for(let j = 0;j<=n;j++){
        strokeWeight(18/a1)
        
        push()
        translate(-c/2 +i*d -d/2,-c/2 +j*d -d/2)
        fill(c4)
        stroke(c4)
        circle(0,0,d/20)
        tmp1 = 4
        for(let h = 0;h<tmp1;h++){
          r = d/3
          stroke(colors1[a3])
          fill(colors1[a3])
          strokeWeight(d/40)
          push()
          rotate(360/tmp1*h)
          line(d/2,0,0,-d/2)
          translate(d/5,0)
          rotate(90)
          leafA()
          pop()
          
          push()
          r = d/10
          stroke(c1)
          fill(c1)
          rotate(360/tmp1*h+45)
          
          translate(d/5,0)
          rotate(90)
          leafA()
          pop()
          
        }
        pop()
        
      }
    }
    borders(0)
    
  }
  if (p ===5){
    background(c1)
    for(let i = 0;i<=n;i++){
      for(let j = 0;j<=n;j++){
        strokeWeight(18/a1)
        push()
        fill(255)
        stroke(255)
        circle(-c/2 +i*d ,-c/2 +j*d  ,d/4)
        circle(-c/2 +i*d ,-c/2 +j*d - d/2 ,d/3)
        circle(-c/2 +i*d -d/2,-c/2 +j*d  ,d/3)
        translate(-c/2 +i*d -d/2,-c/2 +j*d -d/2)
        fill(255)
        stroke(255)
        circle(0,0,d/2)
        tmp1 = 4
        for(let h = 0;h<tmp1;h++){
          r = d/3
          stroke(255)
          fill(colors1[a3])
          strokeWeight(d/40)
          push()
          rotate(360/tmp1*h)
          line(d/2,0,0,-d/2)
          translate(d/5,0)
          rotate(90)
          leafA()
          pop()
          
          push()
          r = d/10
          stroke(c1)
          fill(c1)
          rotate(360/tmp1*h+45)
          
          translate(d/5,0)
          rotate(90)
          leafA()
          pop()
          
        }
        pop()
        
      }
    }   
    borders(a4)
  }
  if (p ===6){
    
    for(let i = 0;i<=n;i++){
      for(let j = 0;j<=n;j++){
        strokeWeight(18/a1)
        push()
        translate(-c/2 +i*d -d/2,-c/2 +j*d -d/2)
        tmp1 = 8
        noFill()
        push()
        scale(0.9)
        for(let h = 0;h<4;h++){
          strokeWeight(1)
          arc(0,d/4,d/4,d/4,0,180)
          arc(0,-d/4,d/4,d/4,180,360)
          arc(-d/4,0, d/4,d/4,90,270)
          arc(d/4,0,d/4,d/4,-90,90)
          push()
          rotate(90*h)
          line(d/4,d/4,d/4,d/4-d/8)
          line(d/4,d/4,d/4-d/8,d/4)
          pop()
        }
        pop()
        push()
        scale(1.1)
        for(let h = 0;h<4;h++){
          strokeWeight(d/30)
          arc(0,d/4,d/4,d/4,0,180)
          arc(0,-d/4,d/4,d/4,180,360)
          arc(-d/4,0, d/4,d/4,90,270)
          arc(d/4,0,d/4,d/4,-90,90)
          push()
          rotate(90*h)
          line(d/4,d/4,d/4,d/4-d/8)
          line(d/4,d/4,d/4-d/8,d/4)
          pop()
        }
        pop()
        for(let h = 0;h<tmp1;h++){
          r = d/3
          stroke(c1)
          noFill()
          strokeWeight(d/40)
          push()
          rotate(360/tmp1*h)
          translate(d/8,0)
          rotate(90)
          leafA()
          // r = d/1.2
          // leafA()
          pop()

        }
        pop()
        
      }
    }    
  }
  if (p ===7){
    
    for(let i = 0;i<=n;i++){
      for(let j = 0;j<=n;j++){
        strokeWeight(18/a1)
        push()
        translate(-c/2 +i*d ,-c/2 +j*d )
        fill(colors1[a3])
        circle(0,0,d/(a3+2))
        tmp1 = 8
        noFill()
        push()
        scale(0.9)
        stroke(colors1[a3])
        for(let h = 0;h<4;h++){
          strokeWeight(1)
          arc(0,d/4,d/4,d/4,0,180)
          arc(0,-d/4,d/4,d/4,180,360)
          arc(-d/4,0, d/4,d/4,90,270)
          arc(d/4,0,d/4,d/4,-90,90)
          push()
          rotate(90*h)
          line(d/4,d/4,d/4,d/4-d/8)
          line(d/4,d/4,d/4-d/8,d/4)
          pop()
        }
        pop()
        push()
        scale(1.1)
        for(let h = 0;h<4;h++){
          strokeWeight(d/30)
          arc(0,d/4,d/4,d/4,0,180)
          arc(0,-d/4,d/4,d/4,180,360)
          arc(-d/4,0, d/4,d/4,90,270)
          arc(d/4,0,d/4,d/4,-90,90)
          push()
          rotate(90*h)
          line(d/4,d/4,d/4,d/4-d/8)
          line(d/4,d/4,d/4-d/8,d/4)
          pop()
        }
        pop()
        push()
        translate(d/2,d/2)
        for(let h = 0;h<tmp1;h++){
          r = d/3
          stroke(c1)
          noFill()
          strokeWeight(d/40)
          push()
          rotate(360/tmp1*h)
          translate(d/8,0)
          rotate(90)
          leafA()
          // r = d/1.2
          // leafA()
          pop()

        }
        pop()
        pop()
        
      }
    }    
  }
  if (p ===8){
    
    for(let i = 0;i<=n;i++){
      for(let j = 0;j<=n;j++){
        strokeWeight(18/a1)
        push()
        translate(-c/2 +i*d ,-c/2 +j*d )
        fill(colors1[a3])
        circle(0,0,d/(a3+2))
        tmp1 = 4
        noFill()
        push()
        scale(2)
        stroke(colors1[a3])
        for(let h = 0;h<4;h++){
          strokeWeight(1)
          arc(0,d/4,d/4,d/4,0,180)
          arc(0,-d/4,d/4,d/4,180,360)
          arc(-d/4,0, d/4,d/4,90,270)
          arc(d/4,0,d/4,d/4,-90,90)
          push()
          rotate(90*h)
          line(d/4,d/4,d/4,d/4-d/8)
          line(d/4,d/4,d/4-d/8,d/4)
          pop()
        }
        pop()
        push()
        scale(1.5)
        for(let h = 0;h<4;h++){
          strokeWeight(d/30)
          arc(0,d/4,d/4,d/4,0,180)
          arc(0,-d/4,d/4,d/4,180,360)
          arc(-d/4,0, d/4,d/4,90,270)
          arc(d/4,0,d/4,d/4,-90,90)
          push()
          rotate(90*h)
          line(d/4,d/4,d/4,d/4-d/8)
          line(d/4,d/4,d/4-d/8,d/4)
          pop()
        }
        pop()
        push()
        translate(d/2,d/2)
        for(let h = 0;h<tmp1;h++){
          r = d/3
          stroke(c1)
          noFill()
          strokeWeight(d/40)
          push()
          rotate(360/tmp1*h)
          translate(d/8,0)
          rotate(90)
          leafA()
          // r = d/1.2
          // leafA()
          pop()

        }
        pop()
        pop()
        
      }
    }    
  }
  if (p ===9){
    
    for(let i = -1;i<=n+1;i++){
      for(let j = -1;j<=n+1;j++){
        strokeWeight(18/a1)
        push()
        translate(-c/2 +i*d ,-c/2 +j*d )
        fill(colors1[a3])
        circle(0,0,d/(a3+2))
        tmp1 = 4
        noFill()
        push()
        scale(1)
        stroke(colors1[a3])
        for(let h = 0;h<4;h++){
          strokeWeight(d/30)
          arc(0,d/4,d/4,d/4,0,180)
          arc(0,-d/4,d/4,d/4,180,360)
          arc(-d/4,0, d/4,d/4,90,270)
          arc(d/4,0,d/4,d/4,-90,90)
          push()
          rotate(90*h)
          line(d/4,d/4,d/4,d/4-d/8)
          line(d/4,d/4,d/4-d/8,d/4)
          pop()
        }
        pop()
        
        push()
        translate(d/2,d/2)
        for(let h = 0;h<tmp1;h++){
          r = d*3
          stroke(c1)
          noFill()
          strokeWeight(d/20)
          push()
          rotate(360/tmp1*h)
          translate(d/8,0)
          rotate(90)
          leafA()
          // r = d/1.2
          // leafA()
          pop()

        }
        pop()
        pop()
        
      }
    }    
  }
  if (p ===10){
    
    for(let i = -1;i<=n+1;i++){
      for(let j = -1;j<=n+1;j++){
        strokeWeight(18/a1)
        push()
        translate(-c/2 +i*d ,-c/2 +j*d )
        
        tmp1 = a3+3
        push()
        translate(d/2,d/2)
        fill(c2)
        circle(0,0,d/(a3+2)/4)
        for(let h = 0;h<tmp1;h++){
          r = d/3
          stroke(c1)
          noFill()
          strokeWeight(d/30)
          push()
          rotate(360/tmp1*h)
          translate(d/4,0)
          rotate(15*a1+30*a3)
          leafD()
          // r = d/1.2
          // leafA()
          pop()

        }
        pop()
        pop()
        
      }
    }    
    borders(a4)
  }
  if (p ===11){
    
    for(let i = -1;i<=n+1;i++){
      for(let j = -1;j<=n+1;j++){
        strokeWeight(18/a1)
        push()
        translate(-c/2 +i*d ,-c/2 +j*d )
        
        tmp1 = a3+3
        push()
        translate(d/2,d/2)
        fill(c2)
        circle(0,0,d/(a3+2)/4)
        for(let h = 0;h<tmp1;h++){
          r = d/3
          stroke(c1)
          noFill()
          strokeWeight(d/20)
          push()
          rotate(360/tmp1*h)
          translate(d/4,0)
          rotate(15*a1+30*a3)
          spiral1()
          // r = d/1.2
          
          pop()

        }
        pop()
        pop()
        
      }
    }    
    borders(a4)
  }
  if (p ===12){
    
    for(let i = -1;i<=n+1;i++){
      for(let j = -1;j<=n+1;j++){
        push()
        translate(-c/2 +i*d ,-c/2 +j*d )
        tmp1 = 4
        push()
        //translate(d/2,d/2)
        for(let h = 0;h<tmp1;h++){
          r = d/2
          stroke(c1)
          noFill()
          strokeWeight(d/30)
          push()
          rotate(360/tmp1*h)
          translate(d/5,0)
          rotate(90)
          spiral1()
          
          pop()

        }
        pop()
        pop()
        
      }
    }    
    
  }
  if (p ===13){
    
    for(let i = -1;i<=n+1;i++){
      for(let j = -1;j<=n+1;j++){
        push()
        translate(-c/2 +i*d ,-c/2 +j*d )
        tmp1 = 4
        push()
        //translate(d/2,d/2)
        if(a1%2===0){
          push()
          stroke(c1)
          noFill()
          strokeWeight(d/30)
          translate(d/2,d/2)
          circle(0,0,d/(a1+3))
          pop()
        }
        for(let h = 0;h<tmp1;h++){
          r = d
          stroke(c1)
          noFill()
          strokeWeight(d/30)
          push()
          rotate(360/tmp1*h)
          translate(d/3,0)
          rotate(90)
          leafC()
          pop()
          if(a2%2===0){
            push()
          r = d/1.5
          rotate(360/tmp1*h)
          translate(d/2,d/3)
          rotate(90)
          leafC()
          pop()
          }
          

        }
        pop()
        pop()
        
      }
    }    
    
  }
  if(p===14){
    s1 = floor(random(npattern))
    patterns(s1)
    s2 = floor(random(npattern))
    patterns(s2)
    
  }
}

function leafA(){

	beginShape()
		for(let i=42;i<138;i++){
			x=-r/3+r/2*sin(i);
			y=r/2*cos(i);
			vertex(x,y)
		}
		for(let i=138;i>42;i--){
			x=r/3-r/2*sin(i);
			y=r/2*cos(i);
			vertex(x,y)
		}
	endShape()
}

function leafB(){	
	beginShape()
		for(let i=42;i<90;i++){
			x=-r/3+r/2*sin(i);
			y=r/2*cos(i);
			vertex(x,y)
		}
		for(let i=-90;i>-120;i--){
			x=r/3+r/6*sin(i);
			y=r/6*cos(i);
			vertex(x,y)
		}
	for(let i=-190;i<-120;i++){
			x=r/3-r/6+r/12*sin(i);
			y=r/12*cos(i);
			vertex(x,y)
		}
	for(let i=-120;i>-180;i--){
			x=r/3-r/6+r/12*sin(i);
			y=r/12*cos(i);
			vertex(x,y)
		}
	for(let i=100;i<139;i++){
			x=-r/3+r/2*sin(i);
			y=r/2*cos(i);
			vertex(x,y)
		}
	for(let i=138;i>99;i--){
			x=r/3-r/2*sin(i);
			y=r/2*cos(i);
			vertex(x,y)
		}	
	for(let i=160;i>120;i--){
			x=-r/3+r/6+r/12*sin(i);
			y=r/12*cos(i);
			vertex(x,y)
		}
	for(let i=120;i<197;i++){
			x=-r/3+r/6+r/12*sin(i);
			y=r/12*cos(i);
			vertex(x,y)
		}
	for(let i=118;i>90;i--){
			x=-r/3+r/6*sin(i);
			y=r/6*cos(i);
			vertex(x,y)
		}
	for(let i=-90;i<-41;i++){
			x=r/3+r/2*sin(i);
			y=r/2*cos(i);
			vertex(x,y)
		}
	endShape()
}

function leafC(){
	
	beginShape()
		for(let i=42;i<138;i++){
			x=-r/2.5+r/3*sin(i);
			y=r/3*cos(i);
			vertex(x,y)
		}
		for(let i=112;i>77;i--){
			x=-r/3-r/6.5+r/3*sin(i);
			y=-r/8+r/3*cos(i);
			vertex(x,y)
		}
	for(let i=-90;i<-77;i++){
			x=r/3+r/2*sin(i);
			y=r/2*cos(i);
			vertex(x,y)
		}
	for(let i=95;i>70;i--){
			x=-r/3-r/6.5+r/3*sin(i);
			y=r/8+r/3*cos(i);
			vertex(x,y)
		}
		
	endShape()
}

function leafD(){
	
	beginShape()
		for(let i=81;i<160;i++){
			x=-r/2.5+r/2*sin(i);
			y=r/2*cos(i);
			vertex(x,y)
			
		}
	for(let i=135;i>80;i--){
			x=-r/2.5-r/10+r/2.4*sin(i);
			y=-r/6+r/2.4*cos(i);
			vertex(x,y)
		}
	for(let i=-95;i<-20;i++){
			x=r/2.5+r/2*sin(i);
			y=r/2*cos(i);
			vertex(x,y)
		}
		for(let i=312;i>257;i--){
			x=r/2.5+r/10+r/2.4*sin(i);
			y=r/6+r/2.4*cos(i);
			vertex(x,y)
		}
		
		
	endShape()
}

function spiral1(){
	
	beginShape()
	for(let i=0;i<180;i++){
			x=r/8*sin(i);
			y=r/8*cos(i);
			vertex(x,y)
		
		}
	for(let i=180;i<360;i++){
			x=r/4*sin(i);
			y=r/8+r/4*cos(i);
			vertex(x,y)
		}
	for(let i=0;i<180;i++){
			x=r/2*sin(i);
			y=-r/8+r/2*cos(i);
			vertex(x,y)
		}
	endShape()
}

function mousePressed(){
  setup()
  draw()
}

function keyPressed(){
  if(keyCode === 38){
    if(p<npattern){
      p ++
    }else{
      p = 0
    } 
  }
  if(keyCode === 40){
    if(p>0){
      p --
    }else{
      p = npattern
    } 
  }
  setup()
  draw()
}
              
            
!
999px

Console