-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
96 lines (80 loc) · 2.98 KB
/
index.html
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<title>Canvas Magic Eraser Tool page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<style>
* {
font-family: sans-serif;
font-size:inherit
}
body {
background:#eee;
font-size:16px;
margin:10px;
padding:0
}
#originalImageCanvas {
border:1px solid #000
}
fieldset {
border:none;
margin:0;
padding:0;
margin-top:1em;
width:300px
}
fieldset > h3 {
margin:.5em 0
}
fieldset > label {
display:block;
font-size:.9em
}
fieldset > input {
margin-bottom:.5em
}
p.small {
font-size:.8em;
}
</style>
</head>
<body>
<div id="canvasWrapper">
<canvas id="originalImageCanvas"></canvas>
</div>
<fieldset>
<h3>Settings</h3>
<p class="small">Hint: Set the "Tollerance" then "Click" on the image to erase an image area background. <br/> It's also possible to undo/reset up to 5 image states backwards.</p>
<label for="tolleranceFied">Tollerance</label>
<input id="tolleranceFied" type="range" name="tollerance" min="0" max="100" value="0"/>
<br/>
<input id="backBtn" type="submit" value="Undo" disabled/>
<input id="resetBtn" type="submit" value="Reset" disabled/>
</fieldset>
<script type="text/javascript" src="js/magicEraser.js"></script>
<script type="text/javascript">
var magicEraser = new MagicEraser(document.getElementById("originalImageCanvas"), "images/twitter-bird.png");
document.getElementById('tolleranceFied').addEventListener('change', function(e) {
magicEraser.tollerance = parseInt(this.value);
}, false);
var backButton = document.getElementById('backBtn'),
resetButton = document.getElementById('resetBtn');
backButton.addEventListener('click', function() {
magicEraser.back();
}, false);
resetButton.addEventListener('click', function() {
magicEraser.reset();
}, false);
magicEraser.stateChanged = function() {
if(this.history.length>1) {
resetButton.removeAttribute('disabled');
backButton.removeAttribute('disabled');
} else {
resetButton.setAttribute('disabled', 'disabled');
backButton.setAttribute('disabled', 'disabled');
}
};
</script>
</body>
</html>