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

Ghost Function: Random Color Ghosts with Arrays
Code by Anthony T. Marasco [2018]

let ghostX, ghostColor;

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


  ghostX = [
    //Here's an array of possible ghost X positions

  /*This array gets filled with the results returned from the randomColorz() function that is designed below. Check it out to see how it works! If we add more ghosts in the ghostX array, we should add more randomColorz() function results to this array.

  ghostColor = [randomColorz(), randomColorz(), randomColorz(), randomColorz()];

function draw() {

  /*In the second section of this for loop, notice our use of
  the .length property to keep the loop running through the entire
  length of our ghostX array. Try adding a new x position into ghostX to add a new ghost to each row!*/

  for (let i = 0; i < 5; i++) {
    for (let y = 60; y <= height - 60; y += 150) {
      ghost(60 * y, y, 1, ghostColor[i]);

//here is our Ghost making 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


//How does this other homemade function work???
function randomColorz() {
  let tempColor = [random(255), random(255), random(255)];

  return tempColor;