Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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

              
                
              
            
!

JS

              
                let ringArrayX = [];//Tree x variable
let ringArrayY = [];//Tree y variable
let nPoints = 15;//number of points in curves

function setup(){
  cnv = createCanvas(620,620)//create canvas
  noLoop(); //no looping draw function
  angleMode(DEGREES); //degrees instead of radians
}


function draw(){
  background(random(10,70),random(10,70),random(10,70))//random background
  translate(width/2,width/2)//make origin be in center
  rIn = random(2,12) //random inner radius
  nRings = int(random(10,50))//random number of rings
  ringMakerInit(rIn,0.5);//initial ring
  for (let i = 0;i<=nRings; i ++){//build array for each ring
    v = random(3,20) //random width
    ringMaker(2,i);//ring function
  }
  for (let i = nRings;i>=0;i--){//draw each ring from the outside in
    stroke(random(0,90),random(0,90),random(0,90));//random stroke color
    strokeWeight(random(0.1,2))//random stroke size
    fill(random(170,190),random(130,150),random(90,110))//random color for ring
    drawRing(ringArrayX[i],ringArrayY[i]);//draw ring function
  }
}

function ringMaker(m,n){
  ringArrayX[n+1] = []
  ringArrayY[n+1] = []
  for (let i =0; i<=nPoints;i++){//create points for curve ring
    ringArrayX[n+1][i] = ringArrayX[n][i] + random(v-m,v+m)*sin(i*(360/nPoints));
    ringArrayY[n+1][i] = ringArrayY[n][i] + random(v-m,v+m)*cos(i*(360/nPoints));
  }
}

function ringMakerInit(r,v){//initial growth
  ringArrayX[0] = [];
  ringArrayY[0] = [];
  for (let i =0; i<=nPoints;i++){
    ringArrayX[0][i] = random(r-v,r+v)*sin(i*(360/nPoints));
    ringArrayY[0][i] = random(r-v,r+v)*cos(i*(360/nPoints));
  }
}

function drawRing(X,Y){//draw ring
  beginShape();
    for (let i = 0;i<=nPoints;i++){
      curveVertex(X[i],Y[i]);
    }
    curveVertex(X[1],Y[1]);
    curveVertex(X[1],Y[1]);
  endShape()
}

function mousePressed(){//reset with mousepress
  translate(-width/2,-width/2)
  draw();
  
}
              
            
!
999px

Console