Pen Settings



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


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


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.


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, body {
  height: 100%;
  background-color: #222;

body {
  display: flex;
  align-items: center;
  justify-content: center;


                // p5.js demo

let colors = {
  a1: "#ff2d5d", a2: "#42dc8e", a3: "#2e43eb", a4: "#ffe359",
  b1: "#96bfed", b2: "#f5ead6", b3: "#f1f3f7", b4: "#e2e6ef"

// start is the starting offset for the sin wave
let start = 0,
    // inc is the increment/speed of the wave. a bigger number means a faster
    // animation and a tighter curve/higher frequency!
    inc = 0.01;

let canvasWidth = 300,
    canvasHeight = canvasWidth;

let pointDiameter = 5,
    // Change me!
    // lineInterval is the no. of px between each line.
    lineInterval = 24;

function setup() {

function draw() {

  let xoff = start;
  // Start x at pointDiameter/2 so that the first ellipse isn't cropped
  for(let x = Math.floor(pointDiameter/2); x < width; x++) {
    let y = sin(xoff)*height/2 + height/2;
    if(x % lineInterval == 0) {
      // Draw the line
      line(x, y, x, height/2);
      // Draw the ellipse
      ellipse(x,y, pointDiameter, pointDiameter);
    // Increase the x offset of the sin function for the next iteration
    xoff += inc;
  // Increase the starting offset, moving along the x axis of the sin function
  start += inc;