LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

    Pixel Art Maker!
    
    


    

Lab: Pixel Art Maker

Choose Grid Size

Grid Height: Grid Width:

Pick A Color

Design Canvas

CSS
body {
    text-align: center;
}

h1 {
    font-family: Monoton;
    font-size: 70px;
    margin: 0.2em;
}

h2 {
    margin: 1em 0 0.25em;
}

h2:first-of-type {
    margin-top: 0.5em;
}

table,
tr,
td {
    border: 1px solid black;
}

table {
    border-collapse: collapse;
    margin: 0 auto;
}

tr {
    height: 20px;
}

td {
    width: 20px;
}

input[type=number] {
    width: 6em;
}
JS
// Function to determine width & height for the table as per user input
function makeGrid() {
// Your code goes here!	

	 var table = $('#pixel_canvas');
	 
// reset the table	
 
     table.children().remove();
// Select size input
     
     var gridWidth = $("#input_width").val();
     var gridHeight = $("#input_height").val();
     for(let i = 0 ; i < gridHeight ;i++){
	     $("#pixel_canvas").append("");
	    }
     for(let x = 0 ; x < gridWidth ; x++){
	     $("tr").append("")
         }
     }
     
// call makeGrid()
const sizePicker = document.querySelector("#sizePicker");
sizePicker.addEventListener("submit", function(e) {
    e.preventDefault();
    makeGrid();
});


//call Color function 
$('#pixel_canvas').on('click', 'td', function () {
// colorPicker  inputs value	
    var selectColor = $('#colorPicker').val();
// set the selected value     
    $(this).css('background-color', selectColor);
});
Wed, 12/27/2017 - 07:02

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv