Pen Settings



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


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.


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.


    <script src=""></script>
    <script src=""></script>
    <script src=""></script>
    <link rel="stylesheet" type="text/css" href="style.css">
    <meta charset="utf-8" />

    <script src="sketch.js"></script>



                html, body {
  margin: 0;
  padding: 0;


                /* PDM Course: Intro to Coding Unit

Making Functions: Part 1 - Creating your own function

//these vairables help to create a "lagging behind" //motion between the pink ghost and our mouse cursor
let xLag = 0;
let yLag = 0;

function setup() {
  createCanvas(windowWidth, windowHeight);

function draw() {
  yLag = yLag + (mouseY - yLag) * 0.04;

  xLag = xLag + (mouseX - xLag) * 0.04;

  /* now we call for function ghost() to be run inside of the draw() function block. We created paramteres inside of our function, so we need to add arguments behind ghost(), passing them into our new function in the order we specified below. This specifies how our ghosts look */

  ghost(200, 345, 1.5, "green");

  // function call - uses the function  

// function declaration - creates the function 
function ghost(ghostX, ghostY, size, gColor) {
  fill(gColor); //body color
  translate(ghostX, ghostY); //Ghost location
  noStroke(); //no outline on body shapes
  rect(-50, 0, 100, 60);
  ellipse(0, 0, 100, 100);
  triangle(-50, 60, -25, 60, -50, 67);
  triangle(-15, 60, 10, 60, -1, 67);
  triangle(25, 60, 50, 60, 50, 67);
  fill(0); //mouth color
  arc(0, 35, 25, 15, 200, 310); //Ghost mouth
  stroke(255); //white stroke color for Ghost eyeballs
  strokeWeight(4); // eyeball size
  fill(71, 96, 255); //eyeball color
  ellipse(25, 0, 25, 25); //Ghost's left eye
  ellipse(-25, 0, 25, 25); //Ghost right eye