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

              
                
              
            
!

JS

              
                //modified from tree ring code
let ringArrayX = [];//Tree x variable
let ringArrayY = [];//Tree y variable
let nPoints = 250;//number of points in curves PLAY WITH THIS NUMBER!
let m = 2;

function setup(){
  cnv = createCanvas(600,600)//create canvas
  stroke(255);
}
function draw(){
  background(0);
  noFill();
  translate(width/2,width/2)//make origin be in center
  str1 = 'Npoints = '+str(nPoints);
  str2 = 'multiplier = '+str(round(m,2));
  text(str1,-width/2+10,width/2-20);
  text(str2,-width/2+10,width/2-5);
  rIn = 200 //radius
  ringMakerInit(rIn,0);//initial ring
  drawRing(ringArrayX[0],ringArrayY[0]);//draw ring function
}

function ringMakerInit(r,v){//initial growth
  ringArrayX[0] = [];
  ringArrayY[0] = [];
  for (let i =0; i<=nPoints;i++){
    ringArrayX[0][i] = r*sin(i*m*(nPoints)+frameCount/100);//CHANGE SPEED BY CHANGING THE 100 AND CHANGE 2 TO CHANGE SHAPE
    ringArrayY[0][i] = r*cos(i*(nPoints)+frameCount/100);
  }
}

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

function mousePressed(){//reset with mousepress
  background(255);
  translate(-width/2,-width/2);
  stroke(random(180,250),random(180,255),random(180,255));
  nPoints = int(random(20,300));
  text(nPoints,-width/2,-width/2);
  frameCount = 0;
  m = random(2,9);
  draw();
}


              
            
!
999px

Console