-
Notifications
You must be signed in to change notification settings - Fork 1
/
simple-shift-test.html
66 lines (64 loc) · 1.39 KB
/
simple-shift-test.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shifting an image using HTML canvas</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background: #4caf50;
margin: 1em;
}
h1 {
font-size: 1.2em;
margin: 0 0 .5em 0;
}
h2 {
font-size: 1.1em;
margin: 0 0 .5em 0;
}
button {
margin: 2em 0;
padding: 0;
border: none;
}
script:not([src]) {
display: block;
white-space: pre;
padding: 0 1em 1em 1em;
color: #fff;
background: #000;
position: relative;
}
script:not([src])::before {
content: "Source code (JavaScript):";
background: orchid;
width: auto;
display: block;
position: fixed;
padding: 2px 5px;
margin: -1em 0 0 -0.5em;
}
</style>
</head>
<body>
<h1>Shifting an image using HTML canvas</h1>
<h2>Simple page</h2>
<p>Click image to shift</p>
<button></button>
<script src="canvasshift.js"></script>
<script>
let c = document.createElement('canvas');
let button = document.querySelector('button');
button.appendChild(c);
const shift = _ => {
button.addEventListener('click', e => {
canvasshift(c, 100, 0);
e.preventDefault();
});
}
canvasshift.load(c, 'puking-unicorn.jpg', shift);
</script>
</body>
</html>