-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeWork_1.html
More file actions
138 lines (108 loc) · 4.7 KB
/
HomeWork_1.html
File metadata and controls
138 lines (108 loc) · 4.7 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE html>
<html>
<body onload="state()" style="background-color:rgb(100,100,110);">
<button onclick='location.replace("index.html")' style=" font-size: 15px; font-family: Segoe UI; font-weight: 100; position: relative; top: 10px; left: 10px;">Вернуться</button>
<h1 style="color:black; text-align:center;">HomeWork</h1>
<style>
svg {
background-color: gray;
}
</style>
<svg height="230" width=" 400">
<rect width="100" height="100" fill=rgb(0,0,255) />
<circle cx="50" cy="50" r="48" stroke="green" stroke-width="4" fill="yellow" />
<polygon points="20,50 45,45 50,20 55,45 80,50 55,55 50,80 45,55" fill=#0066ff stroke=purple stroke-width=1 />
<text x="105" y="0" font-size="32" fill="black" transform="rotate(90 15,10)">POligOn</text>
<text x="6" y="140" font-size="32" fill="black">POligon</text>
<text x="6" y="197" font-size="32" fill="black">POligon</text>
<defs>
<filter id="f1" x="0" y="0" width="200%" height="200%">
<feOffset result="offOut" in="SourceAlpha" dx="5" dy="5" />
<feGaussianBlur result="blurOut" in="offOut" stdDeviation="10" />
<feBlend in="SourceGraphic" in2="offOut" mode="normal" />
</filter>
<linearGradient id="grad1">
<stop offset="20%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
<stop offset="40%" style="stop-color:rgb(0,255,0);stop-opacity:1" />
<stop offset="60%" style="stop-color:rgb(0,0,255);stop-opacity:1" />
<stop offset="80%" style="stop-color:rgb(0,255,0);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(255,0,0);stop-opacity:1" />
</linearGradient>
</defs>
<text x="150" y="50" font-size="40" fill="url(#grad1)" font-family="cursive">ГРАДИЕНТ</text>
<text x="150" y="100" font-size="40" fill="white" font-family="cursive" filter="url(#f1)">ДИЗАЙН</text>
<path d="m 150 170 50 -50 q 5 -5 10 0 l 50 50 q 5 5 0 10 h -110 q -5 -5 0 -10 z" stroke="blue" stroke-width="5" fill="none" />
</svg>
<style>
canvas {
padding: 0;
display: block;
width: 200px;
position: absolute;
top: 350px
}
</style>
<div>
<canvas style="background-color:grey" id="canvas"></canvas>
<script>
var myGamePiece;
function start() {
myGamePiece = new component(30, 30, "red", 10, 120);
myGameArea.start();
}
function state() {
if (started == 0) {
started = 1;
start();
return;
}
if (bo == 1) {
bo = 0;
}
else if (bo == 0) {
bo = 1;
}
}
var myGameArea = {
canvas: canvas,
start: function () {
this.canvas.width = 200;
this.canvas.height = 200;
this.context = this.canvas.getContext("2d");
document.body.insertBefore(this.canvas, document.body.childNodes[0]);
this.interval = setInterval(updateGameArea, 17);
},
clear: function () {
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
}
}
function component(width, height, color, x, y) {
this.width = width;
this.height = height;
this.x = x;
this.y = y;
this.update = function () {
ctx = myGameArea.context;
ctx.fillStyle = color;
ctx.fillRect(this.x, this.y, this.width, this.height);
}
}
var xdir = 1;
var ydir = 1;
var bo = 1;
var started = 0;
function updateGameArea() {
if (bo == 0)
return;
myGameArea.clear();
myGamePiece.x += xdir;
myGamePiece.y += ydir;
if (myGamePiece.x + myGamePiece.width >= myGameArea.canvas.width || myGamePiece.x <= 0) { xdir *= -1 }
if (myGamePiece.y + myGamePiece.height >= myGameArea.canvas.height || myGamePiece.y <= 0) { ydir *= -1 }
myGamePiece.update();
}
</script>
</div>
<button onclick="state()" style="position:relative; left:200px">state</button>
</body>
</html>