forked from Utkarsh9799/Pixel-Art-Maker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDesign.js
38 lines (33 loc) · 856 Bytes
/
Design.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
//Selecting colour, number of rows and columns input
var col = $('#color').val();
//Making the grid
$('#size').on('click', function(){
var row = $('#row').val();
var column =$('#column').val();
$('tr').remove();
$('button').remove();
makeGrid(row,column);
});
function makeGrid(r,c) {
for(var i = 0; i < r; i++){
$('#canvas').append("<tr></tr>");
for(var j = 0; j < c ; j++){
$('tr:last').append("<td></td>");
}
event.preventDefault();
}
$('body').append("<button>Reset</button>");
$('button').attr('id', 'reset');
}
//Filling the cells with the colour
$('body').on('click', 'td', function (){
var col = $('#colourPicker').val();
if($(this).attr('style'))
$(this).removeAttr('style');
else
$(this).css('background-color', col);
});
//Reset button
$('body').on('click', '#reset', function(){
$('td').removeAttr('style');
});