A Pen by Adrian Samuel on CodePen.
Created
January 23, 2018 03:10
-
-
Save Adrian-Samuel/51151aeb486978cce4e3eb411a0636c0 to your computer and use it in GitHub Desktop.
Pixel Art Maker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Pixel Art Maker!</title> | |
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Monoton"> | |
<link rel="stylesheet" href="styles.css"> | |
</head> | |
<body> | |
<h1>Lab: Pixel Art Maker</h1> | |
<h2>Choose Grid Size</h2> | |
<form id="sizePicker"> | |
Grid Height: | |
<input type="number" id="input_height" name="height" min="1" value="1"> | |
Grid Width: | |
<input type="number" id="input_width" name="width" min="1" value="1"> | |
<input type="submit"> | |
</form> | |
<h2>Pick A Color</h2> | |
<input type="color" id="colorPicker"> | |
<input type="reset" value="Reset the form"> | |
<h2>Design Canvas</h2> | |
<table id="pixel_canvas"></table> | |
<script src="designs.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#pixel_canvas').on("click", "td", function() { | |
$(this).css("background-color", $("input[type='color']").val()); | |
}); | |
$('#sizePicker').submit(function(){ | |
let rows = $("#input_height").val(); | |
let columns = $("#input_width").val(); | |
var table = $('#pixel_canvas'); | |
for(x = 0; x <= rows; x++) { | |
var row = $('<tr></tr>').appendTo(table); | |
for(y = 0; y <= columns; y++) { | |
var column = $('<td> </td>').appendTo(row); | |
} | |
} | |
return false; | |
}); | |
$("input[type='reset']").click(function(){ | |
$('tr td').remove(); | |
$("#sizePicker").trigger("reset"); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table { | |
margin: 0 auto; | |
} | |
tr, td { | |
border: 1px solid black; | |
} | |
tr { | |
width: auto; | |
height: auto; | |
} | |
td { | |
height: 50px; | |
width: 50px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment