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

              
                
<html>
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/p5.min.js"></script>
     <script src="https://cdn.jsdelivr.net/gh/molleindustria/p5.play/lib/p5.play.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/addons/p5.dom.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tone/13.8.12/Tone.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
    <meta charset="utf-8" />

  </head>
  <body>
    <script src="sketch.js"></script>
  </body>
</html>

              
            
!

CSS

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

JS

              
                //Objects and Classes 4: Programming Digital Media

//Code by Matthew A. Bardin [2020]

//This code is cerating a circle like in the previous code using a Javascript Object.

// where JSON begins to become more useful is when you have multiple objects. Instead of needing to list out a long line of variables, we can create multiple objects that can be independently ajusted as needed. 

let circle1 = {
  x: 100,
  y: 100,
  diam: 50
};

//here is an example of a simple second object. Notice how we can have the same variable names because they are contained within each object. This can make organizing each value much easier.
let circle2 = {
  x: 200,
  y: 300,
  diam: 50
};

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  fill('purple');
  ellipse(circle1.x, circle1.y, circle1.diam, circle1.diam);

  
  //in order to see our other object, we just need to repeat the process from the previous code, but make sure our varibles are updated to reflect the new object. 
  fill('green');
  ellipse(circle2.x, circle2.y, circle2.diam, circle2.diam);
 
  //take this code as a starting code and add in your own third circle with unique values. Then add a line in order to animate each of the three objects across the canvas.
  
}
              
            
!
999px

Console