-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrgbpov.html
72 lines (59 loc) · 2.16 KB
/
rgbpov.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
<!DOCTYPE html>
<html>
<head>
<title>RGBike POV image converter</title>
<link rel="stylesheet" href="rgbpov.css" />
<!-- Require jQuery -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
<script src="rgbpov.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<h1>rgbpov.js</h1>
<p>RGBike POV image converter</p>
<div class="column">
<form id="image_selection">
<input type="file" name="file" id="image_source" /> <br />
<input type="submit" name="submit" value="Go" />
</form>
<div id="preview">
</div>
<div id="html_output">
</div>
</div>
<div class="column">
<textarea id="c_output" readonly>/* Please select an image to render and hit "Go". It might take some time... */</textarea>
</div>
</div>
<script type="text/javascript">
$(function() {
// Set up file reader
var reader = new FileReader();
// define function to be run when the File
// reader has finished reading the file
reader.onloadend = function(e) {
// Load source image
var source = new Image();
source.onload = function() {
// Initialize rgbpov image
rgbpov.image.initialize(source);
// Convert image to POV
var rgba = rgbpov.make_rgba(); // using nearest-neighbour
//var rgba = rgbpov.make_rgba({}, rgbpov.interp.weighted); // using 2x2 interpolation
// Display POV image
rgbpov.render.HTML(rgba, '#html_output');
rgbpov.render.C(rgba, '#c_output');
}
source.src = e.target.result;
};
$('#image_selection').submit(function(e) {
e.preventDefault();
// Read image ~from user's machine~
var files = $('#image_source')[0].files;
if (files.length == 1)
reader.readAsDataURL(files[0]);
});
});
</script>
</body>
</html>