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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
6 |
+
<title>ECG Simulator</title>
|
7 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/p5.min.js"></script>
|
8 |
+
<style>
|
9 |
+
:root {
|
10 |
+
--bg: #0f0f12;
|
11 |
+
--primary: #00ff88;
|
12 |
+
--accent: #ff0040;
|
13 |
+
--text: #ffffff;
|
14 |
+
--grid: #1e1e2e;
|
15 |
+
--panel: rgba(30, 30, 46, 0.8);
|
16 |
+
--glass: rgba(255, 255, 255, 0.05);
|
17 |
+
}
|
18 |
+
|
19 |
+
* {
|
20 |
+
margin: 0;
|
21 |
+
padding: 0;
|
22 |
+
box-sizing: border-box;
|
23 |
+
}
|
24 |
+
|
25 |
+
body {
|
26 |
+
background: var(--bg);
|
27 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
28 |
+
color: var(--text);
|
29 |
+
overflow-x: hidden;
|
30 |
+
min-height: 100vh;
|
31 |
+
display: grid;
|
32 |
+
place-items: center;
|
33 |
+
background-image:
|
34 |
+
radial-gradient(circle at 20% 30%, rgba(0, 255, 136, 0.03) 0%, transparent 50%),
|
35 |
+
radial-gradient(circle at 80% 70%, rgba(255, 0, 64, 0.03) 0%, transparent 50%);
|
36 |
+
}
|
37 |
+
|
38 |
+
main {
|
39 |
+
width: 100%;
|
40 |
+
max-width: 1200px;
|
41 |
+
padding: 2rem;
|
42 |
+
}
|
43 |
+
|
44 |
+
.ecg-container {
|
45 |
+
position: relative;
|
46 |
+
background: var(--panel);
|
47 |
+
border-radius: 1.5rem;
|
48 |
+
padding: 2rem;
|
49 |
+
box-shadow:
|
50 |
+
0 0 40px rgba(0, 255, 136, 0.1),
|
51 |
+
0 20px 60px rgba(0, 0, 0, 0.3);
|
52 |
+
backdrop-filter: blur(20px);
|
53 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
54 |
+
}
|
55 |
+
|
56 |
+
.header {
|
57 |
+
display: flex;
|
58 |
+
justify-content: space-between;
|
59 |
+
align-items: center;
|
60 |
+
margin-bottom: 1.5rem;
|
61 |
+
flex-wrap: wrap;
|
62 |
+
gap: 1rem;
|
63 |
+
}
|
64 |
+
|
65 |
+
h1 {
|
66 |
+
font-size: clamp(1.5rem, 4vw, 2.5rem);
|
67 |
+
font-weight: 700;
|
68 |
+
background: linear-gradient(135deg, var(--primary), var(--accent));
|
69 |
+
-webkit-background-clip: text;
|
70 |
+
-webkit-text-fill-color: transparent;
|
71 |
+
background-clip: text;
|
72 |
+
}
|
73 |
+
|
74 |
+
.controls {
|
75 |
+
display: flex;
|
76 |
+
align-items: center;
|
77 |
+
gap: 1rem;
|
78 |
+
flex-wrap: wrap;
|
79 |
+
}
|
80 |
+
|
81 |
+
.slider-container {
|
82 |
+
display: flex;
|
83 |
+
align-items: center;
|
84 |
+
gap: 0.75rem;
|
85 |
+
background: var(--glass);
|
86 |
+
padding: 0.75rem 1rem;
|
87 |
+
border-radius: 0.75rem;
|
88 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
89 |
+
}
|
90 |
+
|
91 |
+
label {
|
92 |
+
font-size: 0.875rem;
|
93 |
+
font-weight: 600;
|
94 |
+
color: rgba(255, 255, 255, 0.8);
|
95 |
+
}
|
96 |
+
|
97 |
+
.bpm-display {
|
98 |
+
font-size: 1.125rem;
|
99 |
+
font-weight: 700;
|
100 |
+
color: var(--primary);
|
101 |
+
min-width: 2.5rem;
|
102 |
+
text-align: center;
|
103 |
+
}
|
104 |
+
|
105 |
+
input[type="range"] {
|
106 |
+
width: 150px;
|
107 |
+
height: 4px;
|
108 |
+
background: var(--grid);
|
109 |
+
border-radius: 2px;
|
110 |
+
outline: none;
|
111 |
+
-webkit-appearance: none;
|
112 |
+
cursor: pointer;
|
113 |
+
}
|
114 |
+
|
115 |
+
input[type="range"]::-webkit-slider-thumb {
|
116 |
+
-webkit-appearance: none;
|
117 |
+
width: 18px;
|
118 |
+
height: 18px;
|
119 |
+
background: var(--primary);
|
120 |
+
border-radius: 50%;
|
121 |
+
box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
|
122 |
+
transition: all 0.3s ease;
|
123 |
+
}
|
124 |
+
|
125 |
+
input[type="range"]::-webkit-slider-thumb:hover {
|
126 |
+
transform: scale(1.2);
|
127 |
+
box-shadow: 0 0 20px rgba(0, 255, 136, 0.8);
|
128 |
+
}
|
129 |
+
|
130 |
+
.stats {
|
131 |
+
display: grid;
|
132 |
+
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
133 |
+
gap: 1rem;
|
134 |
+
margin-top: 1.5rem;
|
135 |
+
}
|
136 |
+
|
137 |
+
.stat-card {
|
138 |
+
background: var(--glass);
|
139 |
+
padding: 1rem;
|
140 |
+
border-radius: 0.75rem;
|
141 |
+
text-align: center;
|
142 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
143 |
+
transition: transform 0.3s ease;
|
144 |
+
}
|
145 |
+
|
146 |
+
.stat-card:hover {
|
147 |
+
transform: translateY(-2px);
|
148 |
+
}
|
149 |
+
|
150 |
+
.stat-value {
|
151 |
+
font-size: 1.5rem;
|
152 |
+
font-weight: 700;
|
153 |
+
color: var(--primary);
|
154 |
+
}
|
155 |
+
|
156 |
+
.stat-label {
|
157 |
+
font-size: 0.75rem;
|
158 |
+
color: rgba(255, 255, 255, 0.6);
|
159 |
+
margin-top: 0.25rem;
|
160 |
+
}
|
161 |
+
|
162 |
+
canvas {
|
163 |
+
display: block;
|
164 |
+
border-radius: 0.5rem;
|
165 |
+
background: #000;
|
166 |
+
}
|
167 |
+
|
168 |
+
@media (max-width: 600px) {
|
169 |
+
main {
|
170 |
+
padding: 1rem;
|
171 |
+
}
|
172 |
+
|
173 |
+
.ecg-container {
|
174 |
+
padding: 1.5rem;
|
175 |
+
}
|
176 |
+
|
177 |
+
.header {
|
178 |
+
flex-direction: column;
|
179 |
+
align-items: stretch;
|
180 |
+
}
|
181 |
+
|
182 |
+
.controls {
|
183 |
+
justify-content: center;
|
184 |
+
}
|
185 |
+
|
186 |
+
.slider-container {
|
187 |
+
flex-direction: column;
|
188 |
+
gap: 0.5rem;
|
189 |
+
}
|
190 |
+
|
191 |
+
input[type="range"] {
|
192 |
+
width: 120px;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
.pulse {
|
197 |
+
animation: pulse 1s ease-in-out;
|
198 |
+
}
|
199 |
+
|
200 |
+
@keyframes pulse {
|
201 |
+
0% { transform: scale(1); }
|
202 |
+
50% { transform: scale(1.1); }
|
203 |
+
100% { transform: scale(1); }
|
204 |
+
}
|
205 |
+
</style>
|
206 |
+
</head>
|
207 |
+
<body>
|
208 |
+
<main>
|
209 |
+
<div class="ecg-container">
|
210 |
+
<div class="header">
|
211 |
+
<h1>ECG Simulator</h1>
|
212 |
+
<div class="controls">
|
213 |
+
<div class="slider-container">
|
214 |
+
<label for="bpmSlider">BPM</label>
|
215 |
+
<input type="range" id="bpmSlider" min="40" max="180" value="75" />
|
216 |
+
<span class="bpm-display" id="bpmValue">75</span>
|
217 |
+
</div>
|
218 |
+
</div>
|
219 |
+
</div>
|
220 |
+
<div id="canvas-container"></div>
|
221 |
+
<div class="stats">
|
222 |
+
<div class="stat-card">
|
223 |
+
<div class="stat-value" id="heartRate">75</div>
|
224 |
+
<div class="stat-label">Heart Rate</div>
|
225 |
+
</div>
|
226 |
+
<div class="stat-card">
|
227 |
+
<div class="stat-value" id="rhythm">Sinus</div>
|
228 |
+
<div class="stat-label">Rhythm</div>
|
229 |
+
</div>
|
230 |
+
<div class="stat-card">
|
231 |
+
<div class="stat-value" id="status">Normal</div>
|
232 |
+
<div class="stat-label">Status</div>
|
233 |
+
</div>
|
234 |
+
</div>
|
235 |
+
</div>
|
236 |
+
</main>
|
237 |
+
|
238 |
+
<script>
|
239 |
+
let ecg = [];
|
240 |
+
let currentWaveform = [];
|
241 |
+
let waveIndex = 0;
|
242 |
+
let bpmSlider;
|
243 |
+
let interval = 1000;
|
244 |
+
let heartSize = 20;
|
245 |
+
let beatTimer = 0;
|
246 |
+
|
247 |
+
function setup() {
|
248 |
+
const canvas = createCanvas(windowWidth - 80, 300);
|
249 |
+
canvas.parent('canvas-container');
|
250 |
+
|
251 |
+
bpmSlider = document.getElementById('bpmSlider');
|
252 |
+
const bpmValue = document.getElementById('bpmValue');
|
253 |
+
const heartRate = document.getElementById('heartRate');
|
254 |
+
|
255 |
+
bpmSlider.addEventListener('input', (e) => {
|
256 |
+
bpmValue.textContent = e.target.value;
|
257 |
+
heartRate.textContent = e.target.value;
|
258 |
+
});
|
259 |
+
|
260 |
+
generateWaveform();
|
261 |
+
}
|
262 |
+
|
263 |
+
function draw() {
|
264 |
+
background(0);
|
265 |
+
drawGrid();
|
266 |
+
|
267 |
+
let bpm = parseInt(bpmSlider.value);
|
268 |
+
interval = 60000 / bpm;
|
269 |
+
|
270 |
+
// Stream one waveform point per frame
|
271 |
+
if (waveIndex < currentWaveform.length) {
|
272 |
+
ecg.push(currentWaveform[waveIndex]);
|
273 |
+
waveIndex++;
|
274 |
+
} else {
|
275 |
+
generateWaveform();
|
276 |
+
waveIndex = 0;
|
277 |
+
beatTimer = 10; // Trigger pulse
|
278 |
+
|
279 |
+
// Add pulse animation to heart icon
|
280 |
+
const heartIcon = document.querySelector('.heart-icon');
|
281 |
+
if (heartIcon) {
|
282 |
+
heartIcon.classList.add('pulse');
|
283 |
+
setTimeout(() => heartIcon.classList.remove('pulse'), 1000);
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
// Draw ECG
|
288 |
+
stroke(0, 255, 136);
|
289 |
+
strokeWeight(2);
|
290 |
+
noFill();
|
291 |
+
beginShape();
|
292 |
+
for (let i = 0; i < ecg.length; i++) {
|
293 |
+
vertex(i, height / 2 - ecg[i]);
|
294 |
+
}
|
295 |
+
endShape();
|
296 |
+
|
297 |
+
// Green pulse dot at end
|
298 |
+
let dotY = height / 2 - ecg[ecg.length - 1];
|
299 |
+
fill(0, 255, 136);
|
300 |
+
noStroke();
|
301 |
+
ellipse(ecg.length - 1, dotY, 8);
|
302 |
+
|
303 |
+
// Heart icon
|
304 |
+
push();
|
305 |
+
translate(width - 60, 50);
|
306 |
+
scale((heartSize + sin(frameCount * 0.3) * (beatTimer > 0 ? 6 : 0)) / 100);
|
307 |
+
fill(255, 0, 64);
|
308 |
+
noStroke();
|
309 |
+
beginShape();
|
310 |
+
vertex(0, -30);
|
311 |
+
bezierVertex(-25, -55, -55, -15, 0, 30);
|
312 |
+
bezierVertex(55, -15, 25, -55, 0, -30);
|
313 |
+
endShape(CLOSE);
|
314 |
+
pop();
|
315 |
+
|
316 |
+
if (beatTimer > 0) beatTimer--;
|
317 |
+
|
318 |
+
// Scroll effect: remove leftmost point when full
|
319 |
+
if (ecg.length > width) ecg.shift();
|
320 |
+
}
|
321 |
+
|
322 |
+
function generateWaveform() {
|
323 |
+
currentWaveform = [];
|
324 |
+
|
325 |
+
for (let i = 0; i < 10; i++) currentWaveform.push(0); // baseline
|
326 |
+
for (let i = 0; i < 10; i++) currentWaveform.push(sin(map(i, 0, 10, 0, PI)) * 10); // P wave
|
327 |
+
for (let i = 0; i < 5; i++) currentWaveform.push(-4); // dip
|
328 |
+
for (let i = 0; i < 2; i++) currentWaveform.push(-30); // Q
|
329 |
+
for (let i = 0; i < 2; i++) currentWaveform.push(60); // R
|
330 |
+
for (let i = 0; i < 4; i++) currentWaveform.push(-20); // S
|
331 |
+
for (let i = 0; i < 20; i++) currentWaveform.push(sin(map(i, 0, 20, 0, PI)) * 15); // T
|
332 |
+
for (let i = 0; i < 20; i++) currentWaveform.push(0); // flat after T
|
333 |
+
}
|
334 |
+
|
335 |
+
function drawGrid() {
|
336 |
+
stroke(30, 30, 46);
|
337 |
+
strokeWeight(1);
|
338 |
+
for (let x = 0; x < width; x += 20) {
|
339 |
+
line(x, 0, x, height);
|
340 |
+
}
|
341 |
+
for (let y = 0; y < height; y += 20) {
|
342 |
+
line(0, y, width, y);
|
343 |
+
}
|
344 |
+
}
|
345 |
+
|
346 |
+
function windowResized() {
|
347 |
+
resizeCanvas(windowWidth - 80, 300);
|
348 |
+
}
|
349 |
+
</script>
|
350 |
+
</body>
|
351 |
+
</html>
|