-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
65 lines (55 loc) · 1.74 KB
/
index.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, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<canvas id="canvas" width="800" height="800"></canvas>
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const img1 = document.createElement('IMG');
const img2 = document.createElement('IMG');
const img3 = document.createElement('IMG');
const img4 = document.createElement('IMG');
img1.onload = function () {
ctx.globalCompositeOperation = "source-over";
// ctx.drawImage(img1, 0, 0, 389, 762);
// ctx.globalCompositeOperation = "destination-atop";
ctx.drawImage(img1, 0, 0, 389, 762);
}
img2.onload = function () {
// ctx.globalCompositeOperation = "destination-atop";
// ctx.fillRect(0, 0, 389, 762);
ctx.drawImage(img2, 0, 0, 389, 762);
};
img3.onload = function () {
ctx.globalCompositeOperation = "source-in";
//
ctx.drawImage(img3, 0, 0, 389, 762);
ctx.globalCompositeOperation = "destination-over";
ctx.drawImage(img2, 0, 0, 389, 762);
};
img4.onload = function () {
ctx.globalCompositeOperation = "source-over";
ctx.drawImage(img4, 0, 0, 389, 762);
};
setTimeout(()=>{
img1.src = 'first.png';
},2000);
setTimeout(() => {
img2.src = 'second.png';
}, 500);
setTimeout(() => {
img3.src = 'design2.png';
}, 1000);
setTimeout(() => {
img4.src = 'third.png';
}, 1500);
</script>
</body>
</html>