-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
58 lines (45 loc) · 1.13 KB
/
main.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
var etch = $('#eas-screen'),
board = $('#eas');
$box = $('.box');
// Find RGB background
function findRBG() {
}
// Change background color
function changeBackground() {
}
// Grid function
function grid() {
// Empty grid
etch.html("");
// Create grid
var width = $('#new-width').val(),
boxSize = 480 / width;
for (var i = 0; i < width; i += 1) {
var row = $('<div class="row" id="' + i + '"></div>').css('height', boxSize + "px");
for (var ib = 0; ib < width; ib += 1) {
$('<span class="box"></span>').css({'width': boxSize + "px", 'height': boxSize + "px"}).appendTo(row);
}
etch.append(row);
}
// Color box when mouse hovers
$('.box').mouseenter(function() {
if (board.hasClass('erase')) {
board.removeClass('erase');
}
curOp = parseFloat($(this).css('opacity'));
$(this).css('opacity', curOp + .1);
});
}
// Set new width on click
$('#set-width').on('click', grid);
// Set new width with enter
$('#new-width').on('keydown', function(e) {
if (e.which == 13)
grid();
});
// Reset grid
$('#reset').on('click', function() {
$('#eas').addClass('erase');
$('.box').animate({opacity: 0}, 1000);
});
$(grid);