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

              
                //code by Matthew A. Bardin [2020]

//variables that wil help draw the numbers to the screen
let xLocation, yLocation;

function setup() {
  createCanvas(800, 600);
  background(220);
}

function draw() {
//draws grid on the canvas
  drawGrid();
  
  //puts the square on the bottom corner
  fill(255);
  rect(width - 90, height - 70, width, height);

  //deals with adjusting the numbers present in the X,Y location square
  xLocation = mouseX;
  yLocation = mouseY;
  fill(0);
  textSize(20);
  text("X:", 720, 560);
  text("Y:", 760, 560);
  text(xLocation, 720, 590);
  text(yLocation, 760, 590);

}

//seperate function that draws the grid to the canvas
function drawGrid() {
  textSize(10);
  stroke(200);
  fill(120);
  for (let x = -width; x < width; x += 40) {
    line(x, -height, x, height);
    text(x, x + 1, 12);
  }
  for (let y = -height; y < height; y += 40) {
    line(-width, y, width, y);
    fill(255, 100, 0);
    text(y, 1, y + 12);
  }
}


//seperate function to draw the marked circles whenever the mouse is clicked.
function mousePressed() {
  //draws the circles

  fill(255, 0, 0);
  ellipse(mouseX, mouseY, 40);
  fill(0, 255, 0);
  ellipse(mouseX, mouseY, 30);
  fill(0, 0, 255);
  ellipse(mouseX, mouseY, 20);
  fill(255, 0, 255);
  ellipse(mouseX, mouseY, 10);


  //writes the numbers
  textSize(15);
  fill(0);
  text(xLocation, mouseX + 22, mouseY + 25);
  text(yLocation, mouseX + 50, mouseY + 25);
}
              
            
!
999px

Console