-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path01.basic_image_manager.html
65 lines (57 loc) · 1.47 KB
/
01.basic_image_manager.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi"/>
<style>
html, body {
overflow: hidden;
width: 100%;
height: 100%;
margin:0;
padding:0;
border: 0;
}
</style>
<script src="js/ImageManager.js"></script>
<script>
function init() {
var canvas = initFullScreenCanvas("mainCanvas");
var imageManager = new ImageManager();
imageManager.load({
"arch-left": "img/arch-left.png",
"arch-right": "img/arch-right.png",
"knight": "img/knight.png"
}, onLoaded, onProgress);
}
function onProgress(loaded, total, key, path, success) {
if (success) {
// Progress
console.log("loaded " + loaded + " of " + total);
} else {
// Error handling
console.log("ERROR: could not load " + path);
}
}
function onLoaded() {
console.log("All images are loaded");
}
function initFullScreenCanvas(canvasId) {
var canvas = document.getElementById(canvasId);
resizeCanvas(canvas);
window.addEventListener("resize", function() {
resizeCanvas(canvas);
});
return canvas;
}
function resizeCanvas(canvas) {
canvas.width = document.width || document.body.clientWidth;
canvas.height = document.height || document.body.clientHeight;
}
</script>
</head>
<body onload="init()">
<canvas id="mainCanvas" width="100" height="100"></canvas>
</body>
</html>