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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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.


    <script src=""></script>
     <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;


                //Objects and Classes 6: Programming Digital Media

//Code by Matthew A. Bardin [2020]

//we will start by changing the objects back into blank variable.
let circle1
let circle2
let circle1 = {
  x: 100,
  y: 100,
  diam: 50

let circle2 = {
  x: 200,
  y: 300,
  diam: 50
function setup() {
  createCanvas(400, 400);
  circle1 = new Circle();//in this line we are creating a new object within a class. new is a keyword that will generate a unique instance of this class and store it within the given variable. the name of the variable will replace the keyword 'this' later on in the code.


function draw() {
  background(220, 200, 0);

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

// here is where we are defining the class Circle(). This can be located anywhere within your code as long as it is not in another function. This will contain two main important sections: construction and functionality.
class Circle {
  //in this section we will define everything that makes up the object that we will eventiually make. notice the keyword 'this'. 'this' is used to say that whatever object will be made, the name will replace 'this' and be used to generate an object with the properties. 

  // think of it like you are generating a template to create new objects, and you are creating the presets. However because this is not the object itself, but rather the default values to be applied to the objects later, you don't know the name to put in yet.
  constructor() {
    this.x = 25;
    this.y = 100;
    this.diam = 50;
    this.moveDir = 1;

  // when we are setting up the class, we can also define how the objects will behave. We can format this like a function, however we do not need the keyword function. What we do need is the keyword 'this' 
  move() {
    this.x = this.x + this.moveDir;
    if(this.x >= width - 25){
     this.moveDir = -1;
    } else if (this.x <= 25)
     this.moveDir = 1;

  appear() {
    ellipse(this.x, this.y, this.diam, this.diam);