Update index.html
Browse files- index.html +140 -263
index.html
CHANGED
|
@@ -2,345 +2,222 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<
|
|
|
|
| 6 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.min.js"></script>
|
| 7 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/addons/p5.sound.min.js"></script>
|
| 8 |
<style>
|
| 9 |
body {
|
| 10 |
-
margin: 0;
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
font-family: 'Courier New', Courier, monospace;
|
| 14 |
-
overflow: hidden;
|
| 15 |
-
display: flex;
|
| 16 |
-
flex-direction: column;
|
| 17 |
-
align-items: center;
|
| 18 |
-
justify-content: center;
|
| 19 |
-
height: 100vh;
|
| 20 |
-
}
|
| 21 |
-
canvas {
|
| 22 |
-
border: 1px solid #333;
|
| 23 |
-
box-shadow: 0 0 50px rgba(0, 255, 255, 0.15);
|
| 24 |
-
border-radius: 4px;
|
| 25 |
-
}
|
| 26 |
-
|
| 27 |
-
/* MODE SWITCHER TABS */
|
| 28 |
-
#mode-switcher {
|
| 29 |
-
display: flex;
|
| 30 |
-
gap: 10px;
|
| 31 |
-
margin-bottom: 10px;
|
| 32 |
-
z-index: 20;
|
| 33 |
-
}
|
| 34 |
-
.mode-tab {
|
| 35 |
-
background: #111;
|
| 36 |
-
border: 1px solid #444;
|
| 37 |
-
color: #888;
|
| 38 |
-
padding: 8px 20px;
|
| 39 |
-
cursor: pointer;
|
| 40 |
-
border-radius: 20px;
|
| 41 |
-
font-size: 12px;
|
| 42 |
-
transition: all 0.3s;
|
| 43 |
-
}
|
| 44 |
-
.mode-tab:hover { border-color: cyan; }
|
| 45 |
-
.mode-active {
|
| 46 |
-
background: rgba(0, 255, 255, 0.1);
|
| 47 |
-
border-color: cyan;
|
| 48 |
-
color: cyan;
|
| 49 |
-
font-weight: bold;
|
| 50 |
-
box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
|
| 51 |
-
}
|
| 52 |
-
|
| 53 |
-
#controls {
|
| 54 |
-
z-index: 10;
|
| 55 |
-
background: rgba(0, 0, 0, 0.9);
|
| 56 |
-
padding: 15px 25px;
|
| 57 |
-
border-radius: 12px;
|
| 58 |
-
border: 1px solid #444;
|
| 59 |
-
display: flex;
|
| 60 |
-
flex-direction: column;
|
| 61 |
-
align-items: center;
|
| 62 |
-
gap: 15px;
|
| 63 |
-
min-width: 300px;
|
| 64 |
}
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
background: #111;
|
| 72 |
-
border: 1px solid cyan;
|
| 73 |
-
color: white;
|
| 74 |
-
padding: 8px;
|
| 75 |
-
width: 80%;
|
| 76 |
-
text-align: center;
|
| 77 |
-
border-radius: 4px;
|
| 78 |
-
font-family: inherit;
|
| 79 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
padding: 8px 12px;
|
| 86 |
-
cursor: pointer;
|
| 87 |
-
border-radius: 6px;
|
| 88 |
-
margin: 0 5px;
|
| 89 |
}
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
input[type="file"] { display: none; }
|
| 94 |
-
.custom-upload {
|
| 95 |
-
border: 1px dashed cyan;
|
| 96 |
-
padding: 10px;
|
| 97 |
-
display: block;
|
| 98 |
-
cursor: pointer;
|
| 99 |
-
margin-bottom: 10px;
|
| 100 |
-
color: cyan;
|
| 101 |
-
font-size: 12px;
|
| 102 |
-
}
|
| 103 |
-
.custom-upload:hover { background: rgba(0, 255, 255, 0.1); }
|
| 104 |
-
|
| 105 |
-
#title {
|
| 106 |
-
position: absolute; top: 20px; font-size: 22px; color: cyan; letter-spacing: 3px;
|
| 107 |
-
text-shadow: 0 0 10px rgba(0,255,255,0.5);
|
| 108 |
-
}
|
| 109 |
-
#status { margin-top: 10px; font-size: 10px; color: #666; }
|
| 110 |
</style>
|
| 111 |
</head>
|
| 112 |
<body>
|
| 113 |
-
<div id="title">VERS3DYNAMICS</div>
|
| 114 |
-
|
| 115 |
-
<div id="mode-switcher">
|
| 116 |
-
<div id="tabText" class="mode-tab mode-active">🅰️ TYPE INTENTION</div>
|
| 117 |
-
<div id="tabAudio" class="mode-tab">🅱️ UPLOAD AUDIO</div>
|
| 118 |
-
</div>
|
| 119 |
|
| 120 |
-
<div id="
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
<
|
| 124 |
-
<div style="margin-top:5px; font-size:10px; color:#888;">Typing generates a unique frequency hash.</div>
|
| 125 |
</div>
|
| 126 |
|
| 127 |
-
<div id="
|
| 128 |
-
<
|
| 129 |
-
<input type="file" id="audioUpload" accept="audio/*">
|
| 130 |
-
📂 Select MP3 File
|
| 131 |
-
</label>
|
| 132 |
-
<button id="playPauseBtn" disabled>▶ Play Audio</button>
|
| 133 |
</div>
|
| 134 |
|
| 135 |
-
<div
|
| 136 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
<button id="freezeBtn">❄️ Freeze</button>
|
| 138 |
<button id="clearBtn">✨ Clear</button>
|
| 139 |
<button id="saveBtn">📸 Save</button>
|
| 140 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
</div>
|
| 142 |
-
|
| 143 |
-
<div id="status">Mode: Text Resonance</div>
|
| 144 |
|
| 145 |
<script>
|
| 146 |
-
// --- VARIABLES ---
|
| 147 |
let m = 5, n = 7;
|
| 148 |
-
let particles =
|
| 149 |
let sensitivity = 0.02;
|
| 150 |
-
let
|
| 151 |
-
let currentMode = 'text';
|
| 152 |
-
|
| 153 |
-
// Audio
|
| 154 |
let song, fft, isPlaying = false;
|
| 155 |
-
|
| 156 |
-
// States
|
| 157 |
-
let isMorphing = false;
|
| 158 |
-
let morphSpeed = 0.02;
|
| 159 |
-
|
| 160 |
-
// Freeze Layer
|
| 161 |
let frozenLayer, hasCheckpoint = false;
|
|
|
|
| 162 |
|
| 163 |
function setup() {
|
| 164 |
-
|
|
|
|
|
|
|
| 165 |
pixelDensity(2);
|
|
|
|
| 166 |
colorMode(HSB, 360, 100, 100, 100);
|
| 167 |
background(0);
|
| 168 |
|
| 169 |
-
//
|
| 170 |
-
fft = new p5.FFT(0.8, 64);
|
| 171 |
|
| 172 |
-
// Freeze Setup
|
| 173 |
frozenLayer = createGraphics(width, height);
|
| 174 |
-
frozenLayer.pixelDensity(2);
|
| 175 |
frozenLayer.colorMode(HSB, 360, 100, 100, 100);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
| 178 |
}
|
| 179 |
|
| 180 |
-
function
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
-
// --- TEXT INPUT LOGIC ---
|
| 186 |
select('#wordInput').input(function() {
|
| 187 |
-
if (currentMode !== 'text') return;
|
| 188 |
let word = this.value();
|
| 189 |
-
if
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
val1 += word.charCodeAt(i);
|
| 194 |
-
val2 += word.charCodeAt(i) * (i + 1);
|
| 195 |
-
}
|
| 196 |
-
m = map(val1 % 100, 0, 100, 2, 18);
|
| 197 |
-
n = map(val2 % 100, 0, 100, 2, 18);
|
| 198 |
-
|
| 199 |
-
if(!hasCheckpoint) background(0);
|
| 200 |
-
updateStatus(`Hash Generated: ${word}`);
|
| 201 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 202 |
});
|
| 203 |
|
| 204 |
-
|
| 205 |
-
select('#
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
if
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
select('#playPauseBtn').style('border-color', 'lime');
|
| 214 |
-
});
|
| 215 |
-
}
|
| 216 |
};
|
| 217 |
|
| 218 |
-
select('#
|
| 219 |
-
if
|
| 220 |
-
|
| 221 |
-
song.pause();
|
| 222 |
-
select('#playPauseBtn').html("▶ Play Audio");
|
| 223 |
-
isPlaying = false;
|
| 224 |
-
} else {
|
| 225 |
-
song.play();
|
| 226 |
-
select('#playPauseBtn').html("⏸ Pause");
|
| 227 |
-
isPlaying = true;
|
| 228 |
-
}
|
| 229 |
-
}
|
| 230 |
-
});
|
| 231 |
-
|
| 232 |
-
// --- GLOBAL BUTTONS ---
|
| 233 |
-
select('#morphBtn').mousePressed(() => {
|
| 234 |
-
isMorphing = !isMorphing;
|
| 235 |
-
let btn = select('#morphBtn');
|
| 236 |
-
if(isMorphing) btn.addClass('active-btn');
|
| 237 |
-
else btn.removeClass('active-btn');
|
| 238 |
});
|
| 239 |
|
| 240 |
select('#freezeBtn').mousePressed(() => {
|
| 241 |
-
frozenLayer.clear();
|
| 242 |
frozenLayer.image(get(), 0, 0, width, height);
|
| 243 |
hasCheckpoint = true;
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
let btn = select('#freezeBtn');
|
| 247 |
-
btn.addClass('active-btn');
|
| 248 |
-
setTimeout(() => btn.removeClass('active-btn'), 500);
|
| 249 |
});
|
| 250 |
|
| 251 |
select('#clearBtn').mousePressed(() => {
|
| 252 |
if(hasCheckpoint) image(frozenLayer, 0, 0, width, height);
|
| 253 |
else background(0);
|
| 254 |
});
|
| 255 |
-
|
| 256 |
-
select('#saveBtn').mousePressed(() => saveCanvas('Vers3_Cymatics', 'png'));
|
| 257 |
-
}
|
| 258 |
|
| 259 |
-
|
| 260 |
-
currentMode = mode;
|
| 261 |
-
|
| 262 |
-
// UI Updates
|
| 263 |
-
if (mode === 'text') {
|
| 264 |
-
select('#tabText').addClass('mode-active');
|
| 265 |
-
select('#tabAudio').removeClass('mode-active');
|
| 266 |
-
select('#sectionText').addClass('visible');
|
| 267 |
-
select('#sectionAudio').removeClass('visible');
|
| 268 |
-
|
| 269 |
-
// Stop audio if switching away
|
| 270 |
-
if(song && song.isPlaying()) {
|
| 271 |
-
song.pause();
|
| 272 |
-
isPlaying = false;
|
| 273 |
-
select('#playPauseBtn').html("▶ Play Audio");
|
| 274 |
-
}
|
| 275 |
-
updateStatus("Mode: Text Intention");
|
| 276 |
-
} else {
|
| 277 |
-
select('#tabAudio').addClass('mode-active');
|
| 278 |
-
select('#tabText').removeClass('mode-active');
|
| 279 |
-
select('#sectionAudio').addClass('visible');
|
| 280 |
-
select('#sectionText').removeClass('visible');
|
| 281 |
-
updateStatus("Mode: Audio Injection");
|
| 282 |
-
}
|
| 283 |
}
|
| 284 |
|
| 285 |
-
function
|
| 286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
}
|
| 288 |
|
| 289 |
-
function
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
if (m > 20 || m < 1) morphSpeed *= -1;
|
| 297 |
-
}
|
| 298 |
-
sensitivity = 0.02; // Standard line thickness
|
| 299 |
}
|
|
|
|
| 300 |
|
| 301 |
-
|
|
|
|
| 302 |
if (currentMode === 'audio' && isPlaying) {
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
|
|
|
|
|
|
| 307 |
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
// Fade for trail effect
|
| 319 |
-
background(0, 0, 0, 15);
|
| 320 |
}
|
| 321 |
|
| 322 |
-
|
|
|
|
|
|
|
|
|
|
| 323 |
|
| 324 |
-
//
|
| 325 |
-
strokeWeight(1.5);
|
| 326 |
for (let i = 0; i < particles; i++) {
|
| 327 |
-
let x = random(-1, 1);
|
| 328 |
-
|
|
|
|
|
|
|
| 329 |
|
| 330 |
-
let val = cos(n * PI * x / 2) * cos(m * PI * y / 2) -
|
| 331 |
-
cos(m * PI * x / 2) * cos(n * PI * y / 2);
|
| 332 |
-
|
| 333 |
if (abs(val) < sensitivity) {
|
| 334 |
-
let sx = map(x, -1, 1, 0, width);
|
| 335 |
-
let sy = map(y, -1, 1, 0, height);
|
| 336 |
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
|
| 343 |
-
|
| 344 |
point(sx, sy);
|
| 345 |
}
|
| 346 |
}
|
|
|
|
| 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>Vers3Dynamics Cymatics</title>
|
| 7 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.min.js"></script>
|
| 8 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/addons/p5.sound.min.js"></script>
|
| 9 |
<style>
|
| 10 |
body {
|
| 11 |
+
margin: 0; background: #050505; color: #ccc;
|
| 12 |
+
font-family: 'Courier New', Courier, monospace; overflow: hidden;
|
| 13 |
+
display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
+
/* Canvas now glows slightly */
|
| 16 |
+
canvas { border: 1px solid #333; box-shadow: 0 0 40px rgba(0, 255, 255, 0.05); }
|
| 17 |
|
| 18 |
+
#ui-layer {
|
| 19 |
+
position: absolute; bottom: 20px; z-index: 10;
|
| 20 |
+
background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(5px);
|
| 21 |
+
padding: 15px; border-radius: 12px; border: 1px solid #333;
|
| 22 |
+
display: flex; flex-direction: column; gap: 10px; width: 90%; max-width: 500px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
+
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
|
| 25 |
+
button { background: #111; color: cyan; border: 1px solid #333; padding: 8px 10px; cursor: pointer; border-radius: 4px; font-size: 11px; flex: 1; transition: all 0.2s; }
|
| 26 |
+
button:hover { border-color: cyan; background: #222; }
|
| 27 |
+
.active-btn { background: cyan; color: black; font-weight: bold; border-color: cyan; }
|
| 28 |
|
| 29 |
+
#physics-info {
|
| 30 |
+
height: 30px; font-size: 10px; color: #00ff00;
|
| 31 |
+
border-top: 1px solid #333; padding-top: 10px; margin-top: 5px; text-align: center;
|
| 32 |
+
font-family: monospace; letter-spacing: 1px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
}
|
| 34 |
+
.label { font-size: 9px; color: #666; text-transform: uppercase; }
|
| 35 |
+
input[type="text"] { background: #000; border: 1px solid #333; color: cyan; padding: 8px; width: 100%; box-sizing: border-box; border-radius: 4px; text-align: center;}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
</style>
|
| 37 |
</head>
|
| 38 |
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
<div id="ui-layer">
|
| 41 |
+
<div class="row">
|
| 42 |
+
<button id="textModeBtn" class="active-btn">🅰️ Intention</button>
|
| 43 |
+
<button id="audioModeBtn">🅱️ Acoustic Injection</button>
|
|
|
|
| 44 |
</div>
|
| 45 |
|
| 46 |
+
<div id="textSection" class="row">
|
| 47 |
+
<input type="text" id="wordInput" placeholder="Type intention to root frequency...">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
</div>
|
| 49 |
|
| 50 |
+
<div id="audioSection" class="row" style="display:none;">
|
| 51 |
+
<input type="file" id="audioUpload" accept="audio/*" style="font-size:10px; color:#888;">
|
| 52 |
+
<button id="playBtn" disabled>▶ Play</button>
|
| 53 |
+
</div>
|
| 54 |
+
|
| 55 |
+
<div class="row">
|
| 56 |
+
<button id="physicsToggle">🛠️ Physics</button>
|
| 57 |
<button id="freezeBtn">❄️ Freeze</button>
|
| 58 |
<button id="clearBtn">✨ Clear</button>
|
| 59 |
<button id="saveBtn">📸 Save</button>
|
| 60 |
</div>
|
| 61 |
+
|
| 62 |
+
<div id="physics-info">
|
| 63 |
+
SYSTEM READY
|
| 64 |
+
</div>
|
| 65 |
</div>
|
|
|
|
|
|
|
| 66 |
|
| 67 |
<script>
|
|
|
|
| 68 |
let m = 5, n = 7;
|
| 69 |
+
let particles = 3000;
|
| 70 |
let sensitivity = 0.02;
|
| 71 |
+
let physicsMode = false;
|
| 72 |
+
let currentMode = 'text';
|
|
|
|
|
|
|
| 73 |
let song, fft, isPlaying = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
let frozenLayer, hasCheckpoint = false;
|
| 75 |
+
let canvasSize;
|
| 76 |
|
| 77 |
function setup() {
|
| 78 |
+
// Dynamic Sizing: Fits the screen but leaves room for UI
|
| 79 |
+
canvasSize = min(windowWidth, windowHeight) * 0.9;
|
| 80 |
+
createCanvas(canvasSize, canvasSize);
|
| 81 |
pixelDensity(2);
|
| 82 |
+
|
| 83 |
colorMode(HSB, 360, 100, 100, 100);
|
| 84 |
background(0);
|
| 85 |
|
| 86 |
+
fft = new p5.FFT(0.8); // 0.8 smoothing for less jittery audio
|
|
|
|
| 87 |
|
|
|
|
| 88 |
frozenLayer = createGraphics(width, height);
|
|
|
|
| 89 |
frozenLayer.colorMode(HSB, 360, 100, 100, 100);
|
| 90 |
+
|
| 91 |
+
setupButtons();
|
| 92 |
+
windowResized(); // Force initial sizing check
|
| 93 |
+
}
|
| 94 |
|
| 95 |
+
function windowResized() {
|
| 96 |
+
canvasSize = min(windowWidth, windowHeight) * 0.9;
|
| 97 |
+
resizeCanvas(canvasSize, canvasSize);
|
| 98 |
+
background(0); // Reset background on resize to prevent stretch artifacts
|
| 99 |
}
|
| 100 |
|
| 101 |
+
function setupButtons() {
|
| 102 |
+
select('#physicsToggle').mousePressed(() => {
|
| 103 |
+
physicsMode = !physicsMode;
|
| 104 |
+
let btn = select('#physicsToggle');
|
| 105 |
+
if(physicsMode) btn.addClass('active-btn'); else btn.removeClass('active-btn');
|
| 106 |
+
// Immediate update for feedback
|
| 107 |
+
updatePhysicsText();
|
| 108 |
+
});
|
| 109 |
|
|
|
|
| 110 |
select('#wordInput').input(function() {
|
|
|
|
| 111 |
let word = this.value();
|
| 112 |
+
if(word.length === 0) return;
|
| 113 |
+
let v1 = 0, v2 = 0;
|
| 114 |
+
for (let i = 0; i < word.length; i++) {
|
| 115 |
+
v1 += word.charCodeAt(i); v2 += word.charCodeAt(i) * (i + 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
}
|
| 117 |
+
// Maps to cleaner integer ranges for clearer patterns
|
| 118 |
+
m = map(v1 % 100, 0, 100, 2, 12);
|
| 119 |
+
n = map(v2 % 100, 0, 100, 2, 12);
|
| 120 |
+
if(!hasCheckpoint) background(0);
|
| 121 |
});
|
| 122 |
|
| 123 |
+
select('#textModeBtn').mousePressed(() => switchMode('text'));
|
| 124 |
+
select('#audioModeBtn').mousePressed(() => switchMode('audio'));
|
| 125 |
+
|
| 126 |
+
select('#audioUpload').elt.onchange = (e) => {
|
| 127 |
+
if(song) song.stop();
|
| 128 |
+
song = loadSound(e.target.files[0], () => {
|
| 129 |
+
select('#playBtn').removeAttribute('disabled').html("▶ Play");
|
| 130 |
+
select('#physics-info').html("AUDIO BUFFER LOADED");
|
| 131 |
+
});
|
|
|
|
|
|
|
|
|
|
| 132 |
};
|
| 133 |
|
| 134 |
+
select('#playBtn').mousePressed(() => {
|
| 135 |
+
if(song.isPlaying()) { song.pause(); isPlaying = false; select('#playBtn').html("▶ Play"); }
|
| 136 |
+
else { song.play(); isPlaying = true; select('#playBtn').html("⏸ Pause"); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
});
|
| 138 |
|
| 139 |
select('#freezeBtn').mousePressed(() => {
|
| 140 |
+
frozenLayer.clear(); // Clear buffer before capturing new state
|
| 141 |
frozenLayer.image(get(), 0, 0, width, height);
|
| 142 |
hasCheckpoint = true;
|
| 143 |
+
select('#freezeBtn').html("❄️ Saved");
|
| 144 |
+
setTimeout(() => select('#freezeBtn').html("❄️ Freeze"), 1000);
|
|
|
|
|
|
|
|
|
|
| 145 |
});
|
| 146 |
|
| 147 |
select('#clearBtn').mousePressed(() => {
|
| 148 |
if(hasCheckpoint) image(frozenLayer, 0, 0, width, height);
|
| 149 |
else background(0);
|
| 150 |
});
|
|
|
|
|
|
|
|
|
|
| 151 |
|
| 152 |
+
select('#saveBtn').mousePressed(() => saveCanvas('Vers3Dynamics_Blueprint', 'png'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
}
|
| 154 |
|
| 155 |
+
function switchMode(m) {
|
| 156 |
+
currentMode = m;
|
| 157 |
+
select('#textSection').style('display', m === 'text' ? 'flex' : 'none');
|
| 158 |
+
select('#audioSection').style('display', m === 'audio' ? 'flex' : 'none');
|
| 159 |
+
select('#textModeBtn').toggleClass('active-btn', m === 'text');
|
| 160 |
+
select('#audioModeBtn').toggleClass('active-btn', m === 'audio');
|
| 161 |
}
|
| 162 |
|
| 163 |
+
function updatePhysicsText() {
|
| 164 |
+
if (physicsMode) {
|
| 165 |
+
let traps = floor(m * n * 2); // Approximation of nodal intersections
|
| 166 |
+
let stability = ((m+n)/24*100).toFixed(1);
|
| 167 |
+
select('#physics-info').html(`NODES: ${traps} | CONSOLIDATION: ${stability}%`);
|
| 168 |
+
} else {
|
| 169 |
+
select('#physics-info').html(":: VISUAL RESONANCE ENGINE ::");
|
|
|
|
|
|
|
|
|
|
| 170 |
}
|
| 171 |
+
}
|
| 172 |
|
| 173 |
+
function draw() {
|
| 174 |
+
// AUDIO LOGIC
|
| 175 |
if (currentMode === 'audio' && isPlaying) {
|
| 176 |
+
fft.analyze();
|
| 177 |
+
// Smoother lerp (0.05) prevents jumpy visuals
|
| 178 |
+
m = lerp(m, map(fft.getEnergy("bass"), 0, 255, 2, 10), 0.05);
|
| 179 |
+
n = lerp(n, map(fft.getEnergy("treble"), 0, 255, 2, 14), 0.05);
|
| 180 |
+
background(0, 0, 0, 15); // Trail effect
|
| 181 |
+
}
|
| 182 |
|
| 183 |
+
// PHYSICS GRID (New Feature)
|
| 184 |
+
if (physicsMode) {
|
| 185 |
+
stroke(0, 255, 255, 15); // Very faint cyan
|
| 186 |
+
strokeWeight(1);
|
| 187 |
+
// Draw a simplified engineering grid
|
| 188 |
+
let gridSize = width / 10;
|
| 189 |
+
for(let g = 0; g < width; g+=gridSize) {
|
| 190 |
+
line(g, 0, g, height);
|
| 191 |
+
line(0, g, width, g);
|
| 192 |
+
}
|
|
|
|
|
|
|
| 193 |
}
|
| 194 |
|
| 195 |
+
// PERFORMANCE SAVER: Only update text every 30 frames (approx 0.5s)
|
| 196 |
+
if (frameCount % 30 === 0) {
|
| 197 |
+
updatePhysicsText();
|
| 198 |
+
}
|
| 199 |
|
| 200 |
+
// PARTICLE SYSTEM
|
|
|
|
| 201 |
for (let i = 0; i < particles; i++) {
|
| 202 |
+
let x = random(-1, 1), y = random(-1, 1);
|
| 203 |
+
|
| 204 |
+
// Chladni Equation
|
| 205 |
+
let val = cos(n * PI * x / 2) * cos(m * PI * y / 2) - cos(m * PI * x / 2) * cos(n * PI * y / 2);
|
| 206 |
|
|
|
|
|
|
|
|
|
|
| 207 |
if (abs(val) < sensitivity) {
|
| 208 |
+
let sx = map(x, -1, 1, 0, width), sy = map(y, -1, 1, 0, height);
|
|
|
|
| 209 |
|
| 210 |
+
// Color Logic
|
| 211 |
+
if (physicsMode) {
|
| 212 |
+
// In physics mode, nodes are "Safety Green" to imply engineered structures
|
| 213 |
+
stroke(120, 100, 100, 80);
|
| 214 |
+
} else {
|
| 215 |
+
// In Art mode, we use distance-based coloring
|
| 216 |
+
let d = dist(0,0,x,y);
|
| 217 |
+
stroke((frameCount * 0.5 + d * 100) % 360, 80, 100, 80);
|
| 218 |
+
}
|
| 219 |
|
| 220 |
+
strokeWeight(1.5);
|
| 221 |
point(sx, sy);
|
| 222 |
}
|
| 223 |
}
|