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.


                <!-- Audio from Mihailo Trisic -->
	<audio id="clickSound">
				<source src=""></source>
				<source src=""></source>
				Audio not supported.
			<audio id="clickSound2">
				<source src=""></source>
				<source src=""></source>
				Audio not supported.

<!-- Sketchpad Header -->
<div class="panel panel-primary">
  <div class="panel-heading">
    <h3 class="panel-title text-center"><b>SKETCHPAD 1.0 &nbsp</b><img src=""</h3>
  <div class="panel-body">
     <a class="btn btn-primary settings panelbuttons" href="#" role="button" id="start">Resize</a>
     <a href="" class="btn btn-primary panelbuttons" href="#" role="button" target='_blank' id="projectinfo">Project Info</a>
    <a class='btn btn-primary panelbuttons' href='#' role='button' id='clearcanvas'>Clear </a>
     <a class='btn btn-primary panelbuttons' href='#' role='button' id="btn-download" download="drawing.png">Download</a>

<!-- Bootstrap container -->
 <div class="container">
   <!-- Options menu (Jumbotron) -->
  <div class="jumbotron new-game">
    <div id="exit"> <img src=""</img></div>
    <div id="text">
     <h2 id="mainoptiontext">Options</h2>
    <span class="optionstext">Canvas height:&nbsp<span><input type="text" id="input" placeholder="555px" title="in pixels"></span>
       <span class="optionstext">Canvas width:<span><input type="text" id="input2" placeholder="555px" title="in pixels"></span>

  <p><a id="Confirm" class="btn btn-primary" href="#" role="button">Confirm</a>
  <a  id="Cancel" class="btn btn-danger" href="#" role="button">Cancel</a></p>
     <!-- Canvas (Jumbotron) -->
        <div id="canvasDiv">
        <div class="alert alert-danger" role="alert"> Error: You need to enter a NUMBER higher than 0 to change canvas size.</div>


                /* General */
body {background-color: black;}
h2, h3{cursor:default;}
.panel {background-color:#428bca; border: none;}
.panel-body {margin-top: -14px; margin-bottom: -7px;}
/* Panel buttons */
.panelbuttons {margin-top: 7px; margin-bottom: -7px; border:none;}
/* Options */
.optionstext {cursor:default;text-align: left; font-weight: bold;display: inline-block;}
.new-game {background:darkgray;
   height: 200px;
   margin-top: 250px;
   max-width: 320px;
   padding: 20px;
   z-index: 10;
   position: absolute;
   margin-left: auto;
   margin-right: auto;
   left: 0;
   right: 0;
   top: 80px;
#text {margin-bottom:25px;
margin-top: -35px;
#mainoptiontext{margin-bottom:25px; margin-top: -10px;}

/* Inputs and Checkbox */
#input {width: 90px;height:25px;font-size:small;border:1px solid  black;cursor:auto; margin-bottom: 2px;}
#input2 {width: 90px;height:25px;font-size:small;border:1px solid  black;cursor:auto; margin-left: 10px;}

/* Exit button image and its positioning */ 
#exit{position:relative;top:-15px;left:145px;cursor:pointer;display: inline;}

/* Canvas */
#canvas {background:white; border: 1px solid  red; position:relative; cursor:pointer;}

/* Error warning */
.alert-danger {margin-top: -19px; max-width: 50%; border-radius: 25px; border: 2px solid;font-weight: bold;z-index:5;}


                //Variables ayyy lmao
const minSize = 10;
const maxSize = 128;
var audio = $("#clickSound")[0];
var audio2 = $("#clickSound2")[0];
var clickSound = document.getElementById("clickSound");
clickSound.volume = 0.8;
var clickSound2 = document.getElementById("clickSound2");
clickSound2.volume = 0.8;
var canvasDiv = document.getElementById('canvasDiv');
var canvas = document.createElement('canvas');
canvas.setAttribute('width', 555);
canvas.setAttribute('height', 555);
canvas.setAttribute('id', 'canvas');
if(typeof G_vmlCanvasManager != 'undefined') {
	canvas = G_vmlCanvasManager.initElement(canvas);
  document.write ("Can you please stop using Internet Explorer?")
context = canvas.getContext("2d");

$(document).ready(function () {
  //Set up the starting page
	  $("a, #exit").mousedown(function() {;
	  $("a, #exit").mouseup(function() {;
  //Taking out the garbage
    //Cancel and Exit button 
    $("#exit, .btn-danger").click(function () {
      $(".alert-danger").hide();  $('input:checkbox').removeAttr('checked');
    //Loading up the canvas functions
       //Checking where the mouse is
      var mouseX = e.pageX - this.offsetLeft;
      var mouseY = e.pageY - this.offsetTop;
      paint = true;
      addClick(e.pageX - this.offsetLeft, e.pageY - this.offsetTop);
      //When user is pressing down, draw
        addClick(e.pageX - this.offsetLeft, e.pageY - this.offsetTop, true);
      //On mouse up, don't draw
        paint = false;
      //If mouse leaves the canvas you cant draw
        paint = false;
      //Save the clicks
        var clickX = new Array();
        var clickY = new Array();
        var clickDrag = new Array();
        var paint;

        function addClick(x, y, dragging)
       function redraw(){
         $("#clearcanvas").click(function () {
       context.clearRect(0, 0, context.canvas.width, context.canvas.height); 
        clickX = []; clickY = []; clickDrag = []; 
         context.fillStyle = "#fff"
        context.strokeStyle = "#df4b26";
        context.lineJoin = "round";
        context.lineWidth = 5;
        for(var i=0; i < clickX.length; i++) {		
          if(clickDrag[i] && i){
          context.moveTo(clickX[i-1], clickY[i-1]);
          else {
          context.moveTo(clickX[i]-1, clickY[i]);
          context.lineTo(clickX[i], clickY[i]);
    //Save The Drawing
      var button = document.getElementById('btn-download');
      button.addEventListener('click', function (e) {
      var dataURL = canvas.toDataURL('image/png');
      button.href = dataURL;
   //New Game button toggles options
    $(".settings").click(function () {
  //Confirm button toggles if statement
      $("#Confirm").click(function () {             
  //Calculate the canvas
      var height = $("#input").val();
      var width = $("#input2").val();
      canvas.setAttribute('width', width);
      canvas.setAttribute('height', height);
        //If everythings ok
        if(width.length > 0 && height.length > 0 && $.isNumeric(width) && $.isNumeric(height)) {
          $(".alert-danger").hide();               $("#projectinfo").css('float', 'right');
        else {                                        $(".alert-danger").show();
             canvas.setAttribute('width', 555);
            canvas.setAttribute('height', 555);