-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path01. SoftUni_Draw Triangle, Rect, Arc, Text.html
79 lines (69 loc) · 1.69 KB
/
01. SoftUni_Draw Triangle, Rect, Arc, Text.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
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html>
<head>
<title>pepi First Canvas</title>
</head>
<body>
<canvas width="600" height="400" style="border:2px solid blue" id="canvas">
Canvas not supported
</canvas>
<script type="text/javascript">
drawFillRect();
drawTriangle();
drawSmile();
drawButton();
drawPic();
function drawFillRect() {
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.fillStyle = "blue";
ctx.fillRect(0, 0, 600, 400);
}
function drawTriangle() {
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.moveTo(20, 200);
ctx.lineTo(200, 50);
ctx.lineTo(200, 350);
ctx.fillStyle = "green";
ctx.fill();
}
function drawSmile() {
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.arc(350, 150, 50, 0, Math.PI*2, false);
ctx.moveTo(385, 150);
ctx.arc(350, 150, 35, 0, Math.PI, false);
ctx.moveTo(335, 140);
ctx.arc(330, 140, 4, 0, Math.PI*2, true);
ctx.moveTo(368, 140);
ctx.arc(365, 140, 4, 0, Math.PI*2, true);
ctx.strokeStyle = "white";
ctx.lineWidth = 5;
ctx.stroke();
}
function drawButton() {
let canvas = document.getElementById("canvas");
let ctx = canvas.getContext("2d");
ctx.fillStyle = 'black';
//ctx.fillRect(5, 5, 100, 40);
ctx.strokeStyle = "orange";
ctx.lineCap = "round";
ctx.lineWidth = 30;
ctx.beginPath();
ctx.moveTo(20, 20);
ctx.lineTo(180, 20);
ctx.stroke();
//Text
ctx.fillStyle = 'Black';
ctx.font = "20px monospace";
ctx.textAlign = "center";
ctx.textBaseline = "middle";
ctx.fillText("Button", 100, 20);
}
</script>
</body>
</html>