-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2DDrawImageExample01.htm
More file actions
executable file
·33 lines (26 loc) · 1.05 KB
/
Copy path2DDrawImageExample01.htm
File metadata and controls
executable file
·33 lines (26 loc) · 1.05 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Canvas Draw Image Example</title>
</head>
<body>
<canvas id="drawing" width="200" height="200">Your browser doesn't support the canvas tag.</canvas>
<img id="smiley" src="smile.gif" border="1" title="Image tag" />
<script type="text/javascript">
window.onload = function(){
var drawing = document.getElementById("drawing");
//make sure <canvas> is completely supported
if (drawing.getContext){
var context = drawing.getContext("2d");
var image = document.getElementById("smiley");
//draw regular size
context.drawImage(image, 10, 10);
//draw smaller
context.drawImage(image, 50, 10, 20, 30);
//draw just part of the image
context.drawImage(image, 0, 10, 50, 50, 0, 100, 40, 60);
}
};
</script>
</body>
</html>