-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawing.html
61 lines (50 loc) · 1.48 KB
/
drawing.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
<!DOCTYPE html>
<html>
<body>
<canvas id="myLine" width="200" height="100" style="border:1px solid #FF0000;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("myLine");
var ctx = c.getContext("2d");
ctx.moveTo(0,0);
ctx.lineTo(200,100);
ctx.moveTo(50,0);
ctx.lineTo(50,25);
ctx.moveTo(100,0);
ctx.lineTo(100,50);
ctx.moveTo(150,0);
ctx.lineTo(150,75);
ctx.stroke();
</script>
<canvas id="myCircle" width="200" height="100" style="border:1px solid #0000FF;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("myCircle");
var ctx = c.getContext("2d");
ctx.beginPath();
ctx.arc(95,50,40,0,2*Math.PI);
ctx.stroke();
</script>
<canvas id="myWord" width="300" height="100" style="border:1px solid #00FF00;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c = document.getElementById("myWord");
var ctx = c.getContext("2d");
ctx.font = "30px Arial";
ctx.fillText("Hallo! Wie geht's?",30,50);
</script>
<p>Image to use:</p>
<img id="scream" src="./images/mona_lisa.jpg" style="width:100px">
<p>Canvas to fill:</p>
<canvas id="myCanvas" width="110" height="155" style="border:1px solid #d3d3d3;"></canvas>
<p><button onclick="myCanvas()">Try it</button></p>
<script>
function myCanvas() {
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("scream");
ctx.drawImage(img,5,5,100,145);
}
</script>
</body>
</html>