dron008 commited on
Commit
38df2e5
·
verified ·
1 Parent(s): 2b92873

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +307 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Jsdemo
3
- emoji:
4
  colorFrom: blue
5
- colorTo: purple
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: jsdemo
3
+ emoji: 🐳
4
  colorFrom: blue
5
+ colorTo: blue
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,307 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="ru">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Интерактивная графическая демонстрация</title>
7
+ <style>
8
+ body {
9
+ margin: 0;
10
+ overflow: hidden;
11
+ background: linear-gradient(135deg, #1a1a2e, #16213e);
12
+ display: flex;
13
+ justify-content: center;
14
+ align-items: center;
15
+ height: 100vh;
16
+ font-family: 'Arial', sans-serif;
17
+ color: rgba(255, 255, 255, 0.8);
18
+ }
19
+
20
+ canvas {
21
+ display: block;
22
+ position: fixed;
23
+ top: 0;
24
+ left: 0;
25
+ z-index: 1;
26
+ }
27
+
28
+ .info {
29
+ position: absolute;
30
+ bottom: 20px;
31
+ left: 20px;
32
+ z-index: 2;
33
+ background-color: rgba(0, 0, 0, 0.5);
34
+ padding: 15px;
35
+ border-radius: 10px;
36
+ max-width: 300px;
37
+ }
38
+
39
+ h1 {
40
+ margin: 0 0 10px 0;
41
+ font-size: 18px;
42
+ color: #fff;
43
+ }
44
+
45
+ p {
46
+ margin: 5px 0;
47
+ font-size: 14px;
48
+ line-height: 1.4;
49
+ }
50
+
51
+ .controls {
52
+ position: absolute;
53
+ top: 20px;
54
+ right: 20px;
55
+ z-index: 2;
56
+ display: flex;
57
+ flex-direction: column;
58
+ gap: 10px;
59
+ }
60
+
61
+ button {
62
+ background: rgba(0, 0, 0, 0.5);
63
+ color: white;
64
+ border: 1px solid rgba(255, 255, 255, 0.2);
65
+ border-radius: 5px;
66
+ padding: 8px 12px;
67
+ cursor: pointer;
68
+ transition: all 0.3s ease;
69
+ }
70
+
71
+ button:hover {
72
+ background: rgba(255, 255, 255, 0.1);
73
+ }
74
+ </style>
75
+ </head>
76
+ <body>
77
+ <canvas id="canvas"></canvas>
78
+
79
+ <div class="info">
80
+ <h1>Интерактивная частичная система</h1>
81
+ <p>Двигайте мышью, чтобы влиять на частицы. Нажмите для создания взрыва.</p>
82
+ <p>Частицы реагируют на гравитацию, трение и друг на друга.</p>
83
+ </div>
84
+
85
+ <div class="controls">
86
+ <button id="explode">Создать взрыв</button>
87
+ <button id="changeColor">Изменить цвет</button>
88
+ <button id="toggleLines">Переключить соединения</button>
89
+ </div>
90
+
91
+ <script>
92
+ // Основной код Canvas
93
+ const canvas = document.getElementById('canvas');
94
+ const ctx = canvas.getContext('2d');
95
+
96
+ // Устанавливаем размер canvas равным размеру окна
97
+ canvas.width = window.innerWidth;
98
+ canvas.height = window.innerHeight;
99
+
100
+ // Настройки системы частиц
101
+ const settings = {
102
+ particleCount: 150,
103
+ particleSize: 3,
104
+ lineDistance: 100,
105
+ showLines: true,
106
+ gravity: 0.05,
107
+ friction: 0.98,
108
+ mouseInfluence: 20,
109
+ colors: [
110
+ '#ff3366', '#00ffcc', '#ffcc00', '#33ccff', '#cc33ff',
111
+ '#ff9933', '#66ff33', '#3399ff', '#ff33cc', '#33ff99'
112
+ ],
113
+ currentColorIndex: 0,
114
+ maxVelocity: 5
115
+ };
116
+
117
+ // Функция для генерации случайного числа в диапазоне
118
+ function random(min, max) {
119
+ return Math.random() * (max - min) + min;
120
+ }
121
+
122
+ // Класс частицы
123
+ class Particle {
124
+ constructor(x, y) {
125
+ this.x = x || random(0, canvas.width);
126
+ this.y = y || random(0, canvas.height);
127
+ this.velocityX = random(-1, 1);
128
+ this.velocityY = random(-1, 1);
129
+ this.size = random(1, settings.particleSize);
130
+ this.baseSize = this.size;
131
+ this.color = settings.colors[
132
+ Math.floor(random(0, settings.colors.length))
133
+ ];
134
+ this.hue = Math.floor(random(0, 360));
135
+ this.life = 0;
136
+ this.maxLife = random(200, 1000);
137
+ }
138
+
139
+ // Обновление позиции частицы
140
+ update(mouseX, mouseY) {
141
+ // Расчет расстояния до курсора мыши
142
+ const dx = mouseX - this.x;
143
+ const dy = mouseY - this.y;
144
+ const distance = Math.sqrt(dx * dx + dy * dy);
145
+
146
+ // Влияние мыши на частицу
147
+ if (distance < 100) {
148
+ const angle = Math.atan2(dy, dx);
149
+ const force = (100 - distance) / settings.mouseInfluence;
150
+
151
+ this.velocityX += Math.cos(angle) * force;
152
+ this.velocityY += Math.sin(angle) * force;
153
+ }
154
+
155
+ // Ограничение максимальной скорости
156
+ const speed = Math.sqrt(this.velocityX * this.velocityX + this.velocityY * this.velocityY);
157
+ if (speed > settings.maxVelocity) {
158
+ this.velocityX = (this.velocityX / speed) * settings.maxVelocity;
159
+ this.velocityY = (this.velocityY / speed) * settings.maxVelocity;
160
+ }
161
+
162
+ // Гравитация
163
+ this.velocityY += settings.gravity;
164
+
165
+ // Трение
166
+ this.velocityX *= settings.friction;
167
+ this.velocityY *= settings.friction;
168
+
169
+ // Обновление позиции
170
+ this.x += this.velocityX;
171
+ this.y += this.velocityY;
172
+
173
+ // Столкновение со стенами
174
+ if (this.x < 0 || this.x > canvas.width) {
175
+ this.velocityX *= -0.8;
176
+ this.x = this.x < 0 ? 0 : canvas.width;
177
+ }
178
+
179
+ if (this.y < 0 || this.y > canvas.height) {
180
+ this.velocityY *= -0.8;
181
+ this.y = this.y < 0 ? 0 : canvas.height;
182
+ }
183
+
184
+ // Пульсация размера
185
+ this.life++;
186
+ if (this.life > this.maxLife) this.life = 0;
187
+ const pulse = Math.sin(this.life * 0.05) * 0.5 + 1;
188
+ this.size = this.baseSize * pulse;
189
+
190
+ // Изменение цвета со временем
191
+ this.hue = (this.hue + 0.2) % 360;
192
+ }
193
+
194
+ // Отрисовка частицы
195
+ draw() {
196
+ ctx.fillStyle = `hsla(${this.hue}, 100%, 50%, 0.8)`;
197
+ ctx.beginPath();
198
+ ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
199
+ ctx.fill();
200
+
201
+ // Добавляем свечение
202
+ ctx.shadowBlur = 15;
203
+ ctx.shadowColor = `hsla(${this.hue}, 100%, 50%, 0.6)`;
204
+ }
205
+ }
206
+
207
+ // Создаем частицы
208
+ let particles = [];
209
+ for (let i = 0; i < settings.particleCount; i++) {
210
+ particles.push(new Particle());
211
+ }
212
+
213
+ // Позиция мыши
214
+ let mouseX = canvas.width / 2;
215
+ let mouseY = canvas.height / 2;
216
+
217
+ // Следим за движением мыши
218
+ canvas.addEventListener('mousemove', (e) => {
219
+ mouseX = e.clientX;
220
+ mouseY = e.clientY;
221
+ });
222
+
223
+ // Нажатие мыши создает взрыв
224
+ canvas.addEventListener('mousedown', createExplosion);
225
+
226
+ // Кнопка "Создать взрыв"
227
+ document.getElementById('explode').addEventListener('click', createExplosion);
228
+
229
+ // Кнопка "Изменить цвет"
230
+ document.getElementById('changeColor').addEventListener('click', () => {
231
+ settings.currentColorIndex = (settings.currentColorIndex + 1) % settings.colors.length;
232
+ });
233
+
234
+ // Кнопка "Переключить соединения"
235
+ document.getElementById('toggleLines').addEventListener('click', () => {
236
+ settings.showLines = !settings.showLines;
237
+ });
238
+
239
+ // Функция создания взрыва
240
+ function createExplosion() {
241
+ for (let i = 0; i < particles.length; i++) {
242
+ const angle = random(0, Math.PI * 2);
243
+ const force = random(5, 15);
244
+
245
+ particles[i].velocityX = Math.cos(angle) * force;
246
+ particles[i].velocityY = Math.sin(angle) * force;
247
+ }
248
+ }
249
+
250
+ // Анимационная петля
251
+ function animate() {
252
+ // Очищаем canvas с полупрозрачным фоном для эффекта шлейфа
253
+ ctx.fillStyle = 'rgba(10, 10, 20, 0.2)';
254
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
255
+
256
+ // Обновляем и рисуем частицы
257
+ particles.forEach(particle => particle.update(mouseX, mouseY));
258
+
259
+ // Отрисовываем линии между близкими частицами
260
+ if (settings.showLines) {
261
+ drawConnections();
262
+ }
263
+
264
+ // Рисуем частицы
265
+ particles.forEach(particle => particle.draw());
266
+
267
+ // Сбрасываем тени
268
+ ctx.shadowBlur = 0;
269
+
270
+ requestAnimationFrame(animate);
271
+ }
272
+
273
+ // Рисуем соединения между частицами
274
+ function drawConnections() {
275
+ for (let i = 0; i < particles.length; i++) {
276
+ for (let j = i + 1; j < particles.length; j++) {
277
+ const dx = particles[i].x - particles[j].x;
278
+ const dy = particles[i].y - particles[j].y;
279
+ const distance = Math.sqrt(dx * dx + dy * dy);
280
+
281
+ if (distance < settings.lineDistance) {
282
+ const opacity = 1 - (distance / settings.lineDistance);
283
+ ctx.strokeStyle = `rgba(200, 200, 255, ${opacity * 0.2})`;
284
+ ctx.lineWidth = opacity * 1.5;
285
+ ctx.beginPath();
286
+ ctx.moveTo(particles[i].x, particles[i].y);
287
+ ctx.lineTo(particles[j].x, particles[j].y);
288
+ ctx.stroke();
289
+ }
290
+ }
291
+ }
292
+ }
293
+
294
+ // Обработка изменения размера окна
295
+ window.addEventListener('resize', () => {
296
+ canvas.width = window.innerWidth;
297
+ canvas.height = window.innerHeight;
298
+ });
299
+
300
+ // Запуск анимации
301
+ animate();
302
+
303
+ // Добавляем всплывающие частицы при загрузке
304
+ setTimeout(createExplosion, 500);
305
+ </script>
306
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: absolute; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">This website has been generated by <a href="https://enzostvs-deepsite.hf.space" style="color: #fff;" target="_blank" >DeepSite</a> <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;"></p></body>
307
+ </html>