-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcanvas.html
More file actions
32 lines (25 loc) · 830 Bytes
/
canvas.html
File metadata and controls
32 lines (25 loc) · 830 Bytes
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
<!DOCTYPE html>
<canvas id="canvas" width="200" height="200"></canvas>
<img id="img" src="http://gtms01.alicdn.com/tps/i1/T1TicJFgVcXXab91rk-461-457.png" />
<script>
var canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d'),
img = document.getElementById('img'),
tmp = document.createElement('canvas'),
_ctx = tmp.getContext('2d');
onload = function () {
tmp.width = img.width;
tmp.height = img.height;
_ctx.drawImage(img, 0, 0);
console.time('cvs')
for(var i = 0;i < 1000; i ++) {
ctx.drawImage(tmp, 0, 0);
}
console.timeEnd('cvs')
console.time('img')
for(var i = 0;i < 1000; i ++) {
ctx.drawImage(img, 0, 0);
}
console.timeEnd('img')
}
</script>