-
Notifications
You must be signed in to change notification settings - Fork 76
/
dolly.html
54 lines (41 loc) · 1.33 KB
/
dolly.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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>dolly</title>
</head>
<body>
<h1>dolly</h1>
<p>Change pixel resolution <input type="range" min="4" max="100" value="32" id="range" /> <span id="output">32</span></p>
<div>
<img src="img/dolly1.png" id="dolly1" />
<img src="img/dolly2.png" id="dolly2" />
<img src="img/dolly3.png" id="dolly3" />
</div>
<script src="close-pixelate.js"></script>
<script>
window.onload = function() {
var dolly1 = document.getElementById('dolly1')
var dolly2 = document.getElementById('dolly2')
var dolly3 = document.getElementById('dolly3')
var pixelOpts = [ { resolution: 32 } ]
var pixelDolly1 = dolly1.closePixelate( pixelOpts )
var pixelDolly2 = dolly2.closePixelate( pixelOpts )
var pixelDolly3 = dolly3.closePixelate( pixelOpts )
var range = document.getElementById('range')
var output = document.getElementById('output')
range.addEventListener( 'change', function( event ) {
var res = parseInt( event.target.value, 10 )
res = Math.floor( res / 2 ) * 2
res = Math.max( 4, Math.min( 100, res ) )
output.textContent = res
// console.log( res );
pixelOpts = [ { resolution: res } ]
pixelDolly1.render( pixelOpts )
pixelDolly2.render( pixelOpts )
pixelDolly3.render( pixelOpts )
}, false )
}
</script>
</body>
</html>