-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplop.html
More file actions
100 lines (89 loc) · 1.98 KB
/
plop.html
File metadata and controls
100 lines (89 loc) · 1.98 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
87
88
89
90
91
92
93
94
95
96
97
98
99
<!doctype html>
<html id="html">
<head>
<title>ASDF Sort Pixels Test</title>
<style type="text/css">
html,body {
min-width: 100%;
min-height: 100%;
padding: 0;
margin: 0;
background-position: center center;
}
body {
padding: 0;
margin: 0;
padding-top: 40px;
}
#params {
position: fixed;
top: 0;
left: 0;
background: #fff;
display: none;
}
#square {
position: fixed;
top: 13%;
left: 6%;
width: 25%;
border: 1px solid #000;
box-shadow: 5px 5px 10px #000;
}
</style>
</head>
<body>
<img id="square">
<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;
setImage("test.png");
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);
var uri = sortedCanvas.toDataURL();
document.body.style.backgroundImage = 'url(' + uri + ')';
$("#square").attr('src', uri);
}
}
</script>
</html>