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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                 
var cnt =-60;//counter
var p = -200; //counter to reset animation (also circle coordinate)
function setup() {
  createCanvas(400, 400); //create the canvas
  background(25); //gray background
  stroke(25);//gray background so first circle isn't seen
  fill(25);//gray background
  newABC();//initialize variables for drawing
  strokeWeight(0.5);//thin lines
  fill(255,30);//setting fill for circles to be transparent
}

function draw() {
  translate(width/2,width/2) //translate the canvas so (0,0 is at origin)
  stroke(50-cnt,200+cnt*2,255);//create a gradient color based on x value;
  y1 = (-a1*pow(cnt,2) +b1*cnt+c1)/150  //First parabola y = ax^2 + bx+c 
  y2 = (-a2*pow(cnt,2) +b2*cnt+c2)/600  //second parabola
  line(cnt*5,y1,cnt,y2)//draw line between points of both parabolas
  cnt=cnt+1; //increase counter for x
  if (cnt>60){//draw a new set of parabolas
    newABC();//calculate new a,b,and c values for parabolas
  }
}
function newABC(){
  circle(0,p,5)//draw artistic circles as timers for animation
  circle(0,-p,15)
  a = random(-1,1)//makes both parabolas face the same direction
  a1 = random(-200,200)*a;//random a,b, and c variables:
  b1 = random(-20,20)
  c1 = random(-8000,8000)
  a2 = random(-200,200)*a;
  b2 = random(-20,20)
  c2 = random(-8000,8000)
  cnt = -60;//reset cnt
  p = p+10;//increase circle counter and reset
  if (p>210){//reset after the circle gets to the end
    p = -200;
    background(25);
  }
}
              
            
!
999px

Console