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

              
                <!-- Audio from Mihailo Trisic -->
	<audio id="clickSound">
				<source src="http://mihailo.centarzatalente.com/sounds/click.mp3"></source>
				<source src="http://mihailo.centarzatalente.com/sounds/click.ogg"></source>
				Audio not supported.
			</audio>
			<audio id="clickSound2">
				<source src="http://mihailo.centarzatalente.com/sounds/clickUp.mp3"></source>
				<source src="http://mihailo.centarzatalente.com/sounds/clickUp.ogg"></source>
				Audio not supported.
			</audio>

<!-- 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="https://lh5.ggpht.com/4rWV3qQFONSkmyxanZB-E0dOstKbrZuJ-dSXpmHwnWvLdKIsR7cReJjM_UvjVW1b-KHq=w300"</h3>
  </div>
  <div class="panel-body">
     <a class="btn btn-primary settings panelbuttons" href="#" role="button" id="start">Resize</a>
     <a href="http://www.theodinproject.com/web-development-101/javascript-and-jquery" 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>
  </div>
</div>

<!-- Bootstrap container -->
 <div class="container">
  
   <!-- Options menu (Jumbotron) -->
  
  <div class="jumbotron new-game">
    <center>
    <div id="exit"> <img src="http://www.clker.com/cliparts/f/5/f/0/1349803480867294890Close%20Button.svg.hi.png"</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>
    <br>
       <span class="optionstext">Canvas width:<span><input type="text" id="input2" placeholder="555px" title="in pixels"></span>
    <br>

      </div>
  <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>
      </div>
     </center>
      
    
     <!-- Canvas (Jumbotron) -->
        <center>
        <div id="canvasDiv">
        </div>
        </center>
      
      
      
        <center>
        <div class="alert alert-danger" role="alert"> Error: You need to enter a NUMBER higher than 0 to change canvas size.</div>
      </center>
      
      
      
</div>
              
            
!

CSS

              
                /* 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;}
#projectinfo{float:right;}
/* 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 */ 
img{width:20px;}
#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;}
              
            
!

JS

              
                //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');
canvasDiv.appendChild(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() {
	    audio2.play();
	    });
	  $("a, #exit").mouseup(function() {
	    audio.play();
	    });
  //Taking out the garbage
    $(".new-game").hide();
    $(".alert-danger").hide();
  
    //Cancel and Exit button 
    $("#exit, .btn-danger").click(function () {
      $(".new-game").hide(); 
      $(".alert-danger").hide();  $('input:checkbox').removeAttr('checked');
      $("input[type=text]").val("");
      });
 //-----------------------------------------------//
  
    //Loading up the canvas functions
       //Checking where the mouse is
    $('#canvas').mousedown(function(e){
      var mouseX = e.pageX - this.offsetLeft;
      var mouseY = e.pageY - this.offsetTop;
      
      paint = true;
      addClick(e.pageX - this.offsetLeft, e.pageY - this.offsetTop);
      redraw();
    });
  
      //When user is pressing down, draw
    $('#canvas').mousemove(function(e){
      if(paint){
        addClick(e.pageX - this.offsetLeft, e.pageY - this.offsetTop, true);
        redraw();
        }
      });
    
      //On mouse up, don't draw
      $('#canvas').mouseup(function(e){
        paint = false;
      });
  
      //If mouse leaves the canvas you cant draw
        $('#canvas').mouseleave(function(e){
        paint = false;
      });
  
      //Save the clicks
        var clickX = new Array();
        var clickY = new Array();
        var clickDrag = new Array();
        var paint;

        function addClick(x, y, dragging)
      {
          clickX.push(x);
          clickY.push(y);
          clickDrag.push(dragging);
      }
  
     //Redraw
       function redraw(){
         $("#clearcanvas").click(function () {
       context.clearRect(0, 0, context.canvas.width, context.canvas.height); 
        clickX = []; clickY = []; clickDrag = []; 
         });
         context.fillStyle = "#fff"
  context.fillRect(0,0,canvas.width,canvas.height)
        context.strokeStyle = "#df4b26";
        context.lineJoin = "round";
        context.lineWidth = 5;
			  
        for(var i=0; i < clickX.length; i++) {		
          context.beginPath();
          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]);
          context.closePath();
          context.stroke();
  }   
}
          
  
 
    //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 () {
      $(".new-game").toggle('Drop');
  //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)) {
          $(".new-game").hide();
          $("#canvas").show();
          $(".alert-danger").hide();               $("#projectinfo").css('float', 'right');
          $("#clearcanvas").show();
          $("#savedrawing").show();
        }
        else {                                        $(".alert-danger").show();
             $("#input").focus();
             canvas.setAttribute('width', 555);
            canvas.setAttribute('height', 555);
        }
    });
    }); 
  //-----------------------------------------------//
});

              
            
!
999px

Console