-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesigns.js
39 lines (35 loc) · 830 Bytes
/
designs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const table = $('#pixel_canvas');
function makeGrid() {
const height = parseInt($('#input_height').val());
const width = parseInt($('#input_width').val());
for (let i = 0; i < height; i++) {
table.append('<tr></tr>');
}
for (let i = 0; i < width; i++) {
$('tr').append('<td></td>');
}
}
function clearGrid() {
table.html('');
}
function coloring() {
$('td').mousedown(function(event) {
switch (event.which) {
case 1:
const color = $("input[type='color']").val();
$(this).css('background-color', color);
break;
case 3:
$(this).css('background-color', 'white');
break;
}
});
}
$(document).ready(function(){
$('#sizePicker').submit(function(i){
i.preventDefault();
clearGrid();
makeGrid();
coloring();
});
});