-
Notifications
You must be signed in to change notification settings - Fork 3
/
demo.html
58 lines (53 loc) · 1.89 KB
/
demo.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
<!DOCTYPE html>
<html>
<head>
<title>Demo</title>
<script src="dev/index.js"></script>
<script src="./benchmarks data/medium/rawData.js"></script>
</head>
<style>
#fromexportedimg, #downloadPNG, #downloadWEBP {
display: none;
}
</style>
<script>
"use strict"
window.addEventListener("load", () => {
console.log("rawData", rawData)
// const {minVal, maxVal} = IMGArrays.normalize(rawData)
toIMG.addEventListener("click", () => {
console.log(rawData)
out.innerHTML = ""
fromexportedimg.style.display = "inline-block"
downloadPNG.style.display = "inline-block"
downloadWEBP.style.display = "inline-block"
const canvas = IMGArrays.toIMG(rawData, {capacity: 1})
canvas.id = "theCanvas"
out.appendChild(canvas)
})
fromIMG.addEventListener("click", () => {
const data = IMGArrays.fromIMG(demoImg, {capacity: 1})
console.log(data)
})
fromexportedimg.addEventListener("click", () => {
const data = IMGArrays.fromIMG(out.querySelector("canvas"), {capacity: 1})
// IMGArrays.unnormalize(data, minVal, maxVal)
console.log(data)
})
downloadPNG.addEventListener("click", () => IMGArrays.downloadImage(theCanvas, {name: "image", format: "png"}))
downloadWEBP.addEventListener("click", () => IMGArrays.downloadImage(theCanvas, {name: "image", format: "webp"}))
})
</script>
<body>
Make sure to serve this page using the included server, to avoid cross origin issues
<img id="demoImg" src="fc.png"><br>
<button id="toIMG">Convert raw data to an image</button>
<button id="fromIMG">From above image</button>
<button id="fromexportedimg">From converted image</button>
<br><br>(Open the console)
<button id="downloadWEBP">Download as WEBP</button>
<button id="downloadPNG">Download as PNG</button>
<br><br>
<div id="out"></div>
</body>
</html>