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 3: Programming Digital Media

//Code by Matthew A. Bardin [2020]

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


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

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

function draw() {
  background(220, 200, 0);
  fill('purple');

  ellipse(circle.x, circle.y, circle.diam, circle.diam);

  // now that we have made a static object using JSON and dot notation, lets get it to move across the screen by updating the variables. 
  // we can do this by combining what we just learned about dot notation with what we already know about vairables. 

  // below is a line that will not animate the circle, similar to line 29 in the previous code. 

  // x = x + 1;

  // by adjusting the line above to inlude dot notation, we can make sure our computer knows that it is updating the values within the circle object and that those values will be used to update the position of our ellipse.

  // circle.x = circle.x + 1;
  
  // try adding another line or two in order to change how the circle behaves.
}
              
            
!
999px

Console