-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathlive.html
More file actions
87 lines (76 loc) · 1.75 KB
/
live.html
File metadata and controls
87 lines (76 loc) · 1.75 KB
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
<!doctype html>
<html id="html">
<head>
<title>ASDF Sort Pixels Test</title>
<style type="text/css">
#params {
position: fixed;
top: 0;
left: 0;
background: #fff;
}
html,body {
min-width: 100%;
min-height: 100%;
padding: 0;
margin: 0;
}
body {
padding: 0;
margin: 0;
padding-top: 40px;
}
</style>
</head>
<body>
<div id="params">
<input type="file" id="upload">
iterations <input id="iterations" type="text" value="1" size="2">
mode
<select id="mode">
<option selected value="0">black</option>
<option value="2">white</option>
<option value="1">brightness</option>
</select>
</div>
</body>
<script type="text/javascript" src="vendor/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="vendor/upload.js"></script>
<script type="text/javascript" src="sortpixels.js"></script>
<script type="text/javascript">
new Uploader("html", setImage);
new Uploader("#upload", setImage);
$("#mode").change(function(){
mode = parseInt( $("#mode").val() );
render();
});
$("#iterations").blur(function(){
var newIter = parseInt( $("#iterations").val() );
if (newIter && newIter !== iterations && newIter < 1000) {
iterations = newIter;
render();
} else {
$("#iterations").val(iterations);
}
});
var img, mode = 0, iterations = 1;
function setImage(uri){
img = new Image();
img.onload = function(){
// params:
// - image object
// - mode (0 = black, 1 = brightness, 2 = white, default = 0)
// - iterations (default = 1)
render();
}
img.src = uri;
}
function render(){
if (img) {
var sortedCanvas = sortPixels(img, mode, iterations);
document.body.appendChild(sortedCanvas);
$("body").animate({'scrollTop': $(sortedCanvas).offset().top - 40 }, 300);
}
}
</script>
</html>