Update index.html
Browse files- index.html +176 -206
index.html
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<title>Vers3Dynamics Cymatics
|
| 6 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.min.js"></script>
|
| 7 |
<style>
|
| 8 |
body {
|
|
@@ -19,33 +19,40 @@
|
|
| 19 |
}
|
| 20 |
canvas {
|
| 21 |
border: 1px solid #333;
|
| 22 |
-
box-shadow: 0 0 40px rgba(0, 255, 255, 0.
|
| 23 |
border-radius: 4px;
|
| 24 |
-
transition: box-shadow 0.3s;
|
| 25 |
-
}
|
| 26 |
-
canvas:hover {
|
| 27 |
-
box-shadow: 0 0 60px rgba(0, 255, 255, 0.5), 0 0 100px rgba(138, 43, 226, 0.3);
|
| 28 |
}
|
| 29 |
#controls {
|
| 30 |
-
margin-top:
|
| 31 |
z-index: 10;
|
| 32 |
background: rgba(0, 0, 0, 0.9);
|
| 33 |
-
padding: 15px
|
| 34 |
border-radius: 12px;
|
| 35 |
border: 1px solid #444;
|
| 36 |
-
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
|
| 37 |
display: flex;
|
| 38 |
flex-wrap: wrap;
|
| 39 |
-
gap:
|
| 40 |
align-items: center;
|
| 41 |
-
|
|
|
|
| 42 |
}
|
| 43 |
-
.
|
| 44 |
display: flex;
|
| 45 |
flex-direction: column;
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
-
button,
|
| 49 |
background: #222;
|
| 50 |
color: white;
|
| 51 |
border: 1px solid #444;
|
|
@@ -53,281 +60,244 @@
|
|
| 53 |
cursor: pointer;
|
| 54 |
font-family: inherit;
|
| 55 |
border-radius: 6px;
|
| 56 |
-
|
| 57 |
-
}
|
| 58 |
-
button:hover, select:hover {
|
| 59 |
-
background: #333;
|
| 60 |
-
border-color: cyan;
|
| 61 |
-
transform: translateY(-2px);
|
| 62 |
-
}
|
| 63 |
-
button:active {
|
| 64 |
-
transform: translateY(0);
|
| 65 |
-
}
|
| 66 |
-
.label {
|
| 67 |
-
font-size: 11px;
|
| 68 |
-
color: cyan;
|
| 69 |
-
font-weight: bold;
|
| 70 |
-
text-transform: uppercase;
|
| 71 |
-
letter-spacing: 1px;
|
| 72 |
-
}
|
| 73 |
-
.value-display {
|
| 74 |
-
font-size: 10px;
|
| 75 |
-
color: #888;
|
| 76 |
-
text-align: center;
|
| 77 |
-
}
|
| 78 |
-
input[type="range"] {
|
| 79 |
-
cursor: pointer;
|
| 80 |
-
accent-color: cyan;
|
| 81 |
}
|
|
|
|
| 82 |
.active-btn {
|
| 83 |
-
background:
|
| 84 |
-
color:
|
| 85 |
-
|
| 86 |
font-weight: bold;
|
| 87 |
}
|
|
|
|
| 88 |
#title {
|
| 89 |
-
position: absolute;
|
| 90 |
-
|
| 91 |
-
font-size: 24px;
|
| 92 |
-
color: cyan;
|
| 93 |
-
text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
|
| 94 |
-
letter-spacing: 3px;
|
| 95 |
-
}
|
| 96 |
-
#shortcuts {
|
| 97 |
-
margin-top: 15px;
|
| 98 |
-
font-size: 10px;
|
| 99 |
-
color: #666;
|
| 100 |
-
text-align: center;
|
| 101 |
-
letter-spacing: 1px;
|
| 102 |
}
|
| 103 |
</style>
|
| 104 |
</head>
|
| 105 |
<body>
|
| 106 |
-
<div id="title">VERS3DYNAMICS
|
| 107 |
|
| 108 |
<div id="controls">
|
| 109 |
-
<div class="
|
| 110 |
-
<span class="label">
|
| 111 |
-
<input type="
|
| 112 |
-
</div>
|
| 113 |
-
<div class="control-group">
|
| 114 |
-
<span class="label">Freq N: <span id="nVal">7.0</span></span>
|
| 115 |
-
<input type="range" id="nSlider" min="1" max="20" step="0.1" value="7">
|
| 116 |
</div>
|
| 117 |
-
|
| 118 |
-
|
|
|
|
| 119 |
<select id="paletteSelect">
|
| 120 |
<option value="cyan">Cyan Classic</option>
|
| 121 |
<option value="rainbow">Rainbow Flow</option>
|
| 122 |
<option value="fire">Fire Gradient</option>
|
| 123 |
-
<option value="aurora">Aurora Borealis</option>
|
| 124 |
<option value="quantum">Quantum Purple</option>
|
| 125 |
</select>
|
| 126 |
</div>
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
</
|
| 132 |
-
<
|
| 133 |
-
<span class="label">Sensitivity</span>
|
| 134 |
-
<input type="range" id="sensitivitySlider" min="0.005" max="0.05" step="0.005" value="0.02">
|
| 135 |
-
<span class="value-display" id="sensVal">0.02</span>
|
| 136 |
-
</div>
|
| 137 |
-
<button id="morphBtn">🌀 Auto-Morph: OFF</button>
|
| 138 |
-
<button id="symmetryBtn">⚡ Symmetry Boost</button>
|
| 139 |
-
<button id="pulseBtn">💫 Pulse Effect</button>
|
| 140 |
-
<button id="freezeBtn">❄️ Freeze Checkpoint</button>
|
| 141 |
-
<button id="clearBtn">✨ Clear / Restore</button>
|
| 142 |
<button id="saveBtn">📸 Save PNG</button>
|
| 143 |
</div>
|
| 144 |
-
|
| 145 |
-
<div
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
</div>
|
| 148 |
|
| 149 |
<script>
|
|
|
|
| 150 |
let m = 5;
|
| 151 |
let n = 7;
|
| 152 |
-
let
|
| 153 |
-
let morphSpeed = 0.02;
|
| 154 |
-
let particles = 4000;
|
| 155 |
let sensitivity = 0.02;
|
| 156 |
let currentPalette = 'cyan';
|
| 157 |
let hueOffset = 0;
|
|
|
|
|
|
|
|
|
|
| 158 |
let symmetryMode = false;
|
| 159 |
let pulseMode = false;
|
| 160 |
let pulsePhase = 0;
|
| 161 |
-
|
| 162 |
-
|
|
|
|
| 163 |
let frozenLayer;
|
| 164 |
-
let hasCheckpoint = false;
|
| 165 |
|
| 166 |
function setup() {
|
| 167 |
-
|
| 168 |
pixelDensity(2);
|
| 169 |
-
background(0);
|
| 170 |
-
colorMode(HSB, 360, 100, 100, 100);
|
| 171 |
|
| 172 |
-
//
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
}
|
| 176 |
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
let densitySlider = select('#densitySlider');
|
| 185 |
-
densitySlider.input(() => {
|
| 186 |
-
particles = parseInt(densitySlider.value());
|
| 187 |
-
select('#densityVal').html(particles);
|
| 188 |
-
});
|
| 189 |
-
|
| 190 |
-
let sensSlider = select('#sensitivitySlider');
|
| 191 |
-
sensSlider.input(() => {
|
| 192 |
-
sensitivity = parseFloat(sensSlider.value());
|
| 193 |
-
select('#sensVal').html(sensitivity.toFixed(3));
|
| 194 |
-
});
|
| 195 |
-
|
| 196 |
-
select('#paletteSelect').changed(function() {
|
| 197 |
-
currentPalette = this.value();
|
| 198 |
-
});
|
| 199 |
-
|
| 200 |
-
select('#saveBtn').mousePressed(saveHighRes);
|
| 201 |
|
| 202 |
-
//
|
| 203 |
-
select('#
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
}
|
| 211 |
});
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
morphBtn.mousePressed(() => {
|
| 215 |
isMorphing = !isMorphing;
|
| 216 |
-
|
| 217 |
-
if(isMorphing) morphBtn.addClass('active-btn');
|
| 218 |
-
else morphBtn.removeClass('active-btn');
|
| 219 |
});
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
symBtn.mousePressed(() => {
|
| 223 |
symmetryMode = !symmetryMode;
|
| 224 |
-
|
| 225 |
-
if(symmetryMode) symBtn.addClass('active-btn');
|
| 226 |
-
else symBtn.removeClass('active-btn');
|
| 227 |
});
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
pulseBtn.mousePressed(() => {
|
| 231 |
pulseMode = !pulseMode;
|
| 232 |
-
|
| 233 |
-
if(pulseMode) pulseBtn.addClass('active-btn');
|
| 234 |
-
else pulseBtn.removeClass('active-btn');
|
| 235 |
});
|
| 236 |
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
freezeBtn.mousePressed(() => {
|
| 240 |
-
// Save current canvas state to buffer
|
| 241 |
frozenLayer.clear();
|
| 242 |
-
frozenLayer.image(get(), 0, 0);
|
| 243 |
hasCheckpoint = true;
|
| 244 |
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
setTimeout(() => {
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
}
|
| 254 |
|
| 255 |
function draw() {
|
| 256 |
-
//
|
|
|
|
| 257 |
if (isMorphing) {
|
| 258 |
-
background(0, 0, 0,
|
| 259 |
m += morphSpeed * 0.6;
|
| 260 |
n += morphSpeed * 0.4;
|
| 261 |
if (m > 20 || m < 1) morphSpeed *= -1;
|
| 262 |
|
| 263 |
-
// Sync
|
| 264 |
select('#mSlider').value(m);
|
| 265 |
select('#nSlider').value(n);
|
| 266 |
-
select('#mVal').html(m.toFixed(1));
|
| 267 |
-
select('#nVal').html(n.toFixed(1));
|
| 268 |
}
|
| 269 |
-
|
| 270 |
-
// Pulse Logic
|
| 271 |
if (pulseMode) {
|
| 272 |
pulsePhase += 0.05;
|
| 273 |
sensitivity = 0.02 + 0.015 * sin(pulsePhase);
|
| 274 |
-
|
|
|
|
| 275 |
}
|
| 276 |
-
|
| 277 |
hueOffset += 0.5;
|
| 278 |
-
|
| 279 |
-
// CRITICAL FIX: We do NOT draw the frozen layer here.
|
| 280 |
-
// We only draw it when "Clear/Restore" is clicked.
|
| 281 |
-
// This ensures new particles can accumulate on top.
|
| 282 |
|
| 283 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 284 |
for (let i = 0; i < particles; i++) {
|
| 285 |
let x = random(-1, 1);
|
| 286 |
let y = random(-1, 1);
|
| 287 |
|
| 288 |
-
|
| 289 |
-
|
|
|
|
| 290 |
|
| 291 |
-
if (
|
| 292 |
-
let
|
| 293 |
-
let
|
| 294 |
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
point(
|
| 298 |
|
| 299 |
if (symmetryMode) {
|
| 300 |
-
|
| 301 |
-
point(
|
| 302 |
-
point(
|
| 303 |
-
point(width - screenX, height - screenY);
|
| 304 |
}
|
| 305 |
}
|
| 306 |
}
|
| 307 |
}
|
| 308 |
|
| 309 |
-
function
|
| 310 |
-
let
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 318 |
}
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
function saveHighRes() {
|
| 322 |
-
saveCanvas('Vers3Dynamics_Pattern_' + Date.now(), 'png');
|
| 323 |
-
}
|
| 324 |
-
|
| 325 |
-
function keyPressed() {
|
| 326 |
-
if (key === 'm' || key === 'M') select('#morphBtn').mousePressed();
|
| 327 |
-
else if (key === 'c' || key === 'C') select('#clearBtn').mousePressed();
|
| 328 |
-
else if (key === 's' || key === 'S') saveHighRes();
|
| 329 |
-
else if (key === 'p' || key === 'P') select('#pulseBtn').mousePressed();
|
| 330 |
-
else if (key === 'f' || key === 'F') select('#freezeBtn').mousePressed();
|
| 331 |
}
|
| 332 |
</script>
|
| 333 |
</body>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<title>Vers3Dynamics Cymatics</title>
|
| 6 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.min.js"></script>
|
| 7 |
<style>
|
| 8 |
body {
|
|
|
|
| 19 |
}
|
| 20 |
canvas {
|
| 21 |
border: 1px solid #333;
|
| 22 |
+
box-shadow: 0 0 40px rgba(0, 255, 255, 0.2);
|
| 23 |
border-radius: 4px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
}
|
| 25 |
#controls {
|
| 26 |
+
margin-top: 15px;
|
| 27 |
z-index: 10;
|
| 28 |
background: rgba(0, 0, 0, 0.9);
|
| 29 |
+
padding: 15px;
|
| 30 |
border-radius: 12px;
|
| 31 |
border: 1px solid #444;
|
|
|
|
| 32 |
display: flex;
|
| 33 |
flex-wrap: wrap;
|
| 34 |
+
gap: 10px;
|
| 35 |
align-items: center;
|
| 36 |
+
justify-content: center;
|
| 37 |
+
max-width: 95vw;
|
| 38 |
}
|
| 39 |
+
.input-group {
|
| 40 |
display: flex;
|
| 41 |
flex-direction: column;
|
| 42 |
+
align-items: center;
|
| 43 |
+
}
|
| 44 |
+
/* New Text Input Style */
|
| 45 |
+
#wordInput {
|
| 46 |
+
background: #111;
|
| 47 |
+
border: 1px solid cyan;
|
| 48 |
+
color: white;
|
| 49 |
+
padding: 8px;
|
| 50 |
+
font-family: inherit;
|
| 51 |
+
border-radius: 4px;
|
| 52 |
+
width: 150px;
|
| 53 |
+
text-align: center;
|
| 54 |
}
|
| 55 |
+
button, select {
|
| 56 |
background: #222;
|
| 57 |
color: white;
|
| 58 |
border: 1px solid #444;
|
|
|
|
| 60 |
cursor: pointer;
|
| 61 |
font-family: inherit;
|
| 62 |
border-radius: 6px;
|
| 63 |
+
min-width: 100px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
}
|
| 65 |
+
button:hover { border-color: cyan; }
|
| 66 |
.active-btn {
|
| 67 |
+
background: #004444;
|
| 68 |
+
border-color: cyan;
|
| 69 |
+
color: cyan;
|
| 70 |
font-weight: bold;
|
| 71 |
}
|
| 72 |
+
.label { font-size: 10px; color: cyan; text-transform: uppercase; margin-bottom: 3px;}
|
| 73 |
#title {
|
| 74 |
+
position: absolute; top: 15px; font-size: 20px; color: cyan; letter-spacing: 2px;
|
| 75 |
+
text-shadow: 0 0 10px rgba(0,255,255,0.5);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
}
|
| 77 |
</style>
|
| 78 |
</head>
|
| 79 |
<body>
|
| 80 |
+
<div id="title">VERS3DYNAMICS RESONANCE ENGINE</div>
|
| 81 |
|
| 82 |
<div id="controls">
|
| 83 |
+
<div class="input-group">
|
| 84 |
+
<span class="label">Input Word / Intention</span>
|
| 85 |
+
<input type="text" id="wordInput" placeholder="Type here...">
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
</div>
|
| 87 |
+
|
| 88 |
+
<div class="input-group">
|
| 89 |
+
<span class="label">Color Palette</span>
|
| 90 |
<select id="paletteSelect">
|
| 91 |
<option value="cyan">Cyan Classic</option>
|
| 92 |
<option value="rainbow">Rainbow Flow</option>
|
| 93 |
<option value="fire">Fire Gradient</option>
|
|
|
|
| 94 |
<option value="quantum">Quantum Purple</option>
|
| 95 |
</select>
|
| 96 |
</div>
|
| 97 |
+
|
| 98 |
+
<button id="morphBtn">🌀 Auto-Morph</button>
|
| 99 |
+
<button id="symmetryBtn">⚡ Symmetry</button>
|
| 100 |
+
<button id="pulseBtn">💫 Pulse</button>
|
| 101 |
+
<button id="freezeBtn">❄️ Freeze Layer</button>
|
| 102 |
+
<button id="clearBtn">✨ Clear All</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
<button id="saveBtn">📸 Save PNG</button>
|
| 104 |
</div>
|
| 105 |
+
|
| 106 |
+
<div style="margin-top:10px; color:#555; font-size:10px;">
|
| 107 |
+
Use Sliders (Below) for Fine Tuning
|
| 108 |
+
</div>
|
| 109 |
+
|
| 110 |
+
<div id="sliders" style="display:flex; gap:20px; margin-top:10px; background:rgba(0,0,0,0.5); padding:10px; border-radius:8px;">
|
| 111 |
+
<div><span class="label">Freq M: </span><input type="range" id="mSlider" min="1" max="20" step="0.1" value="5"></div>
|
| 112 |
+
<div><span class="label">Freq N: </span><input type="range" id="nSlider" min="1" max="20" step="0.1" value="7"></div>
|
| 113 |
</div>
|
| 114 |
|
| 115 |
<script>
|
| 116 |
+
// --- Global Variables ---
|
| 117 |
let m = 5;
|
| 118 |
let n = 7;
|
| 119 |
+
let particles = 3000;
|
|
|
|
|
|
|
| 120 |
let sensitivity = 0.02;
|
| 121 |
let currentPalette = 'cyan';
|
| 122 |
let hueOffset = 0;
|
| 123 |
+
|
| 124 |
+
// Toggle States
|
| 125 |
+
let isMorphing = false;
|
| 126 |
let symmetryMode = false;
|
| 127 |
let pulseMode = false;
|
| 128 |
let pulsePhase = 0;
|
| 129 |
+
let morphSpeed = 0.02;
|
| 130 |
+
|
| 131 |
+
// Freeze Layer Buffer
|
| 132 |
let frozenLayer;
|
| 133 |
+
let hasCheckpoint = false;
|
| 134 |
|
| 135 |
function setup() {
|
| 136 |
+
createCanvas(600, 600);
|
| 137 |
pixelDensity(2);
|
|
|
|
|
|
|
| 138 |
|
| 139 |
+
// IMPORTANT: Set p5 colorMode inside setup
|
| 140 |
+
colorMode(HSB, 360, 100, 100, 100);
|
| 141 |
+
background(0);
|
|
|
|
| 142 |
|
| 143 |
+
// Initialize Freeze Layer
|
| 144 |
+
frozenLayer = createGraphics(width, height);
|
| 145 |
+
frozenLayer.pixelDensity(2);
|
| 146 |
+
frozenLayer.colorMode(HSB, 360, 100, 100, 100);
|
| 147 |
+
|
| 148 |
+
// --- Attach Event Listeners ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
+
// 1. TEXT INPUT LOGIC (The AI Hash)
|
| 151 |
+
select('#wordInput').input(function() {
|
| 152 |
+
let word = this.value();
|
| 153 |
+
if (word.length > 0) {
|
| 154 |
+
// Simple hash function to turn text into math
|
| 155 |
+
let val1 = 0;
|
| 156 |
+
let val2 = 0;
|
| 157 |
+
for (let i = 0; i < word.length; i++) {
|
| 158 |
+
val1 += word.charCodeAt(i);
|
| 159 |
+
val2 += word.charCodeAt(i) * (i + 1);
|
| 160 |
+
}
|
| 161 |
+
// Map hash to Frequency Range (1-20)
|
| 162 |
+
m = map(val1 % 100, 0, 100, 2, 18);
|
| 163 |
+
n = map(val2 % 100, 0, 100, 2, 18);
|
| 164 |
+
|
| 165 |
+
// Update sliders to match text
|
| 166 |
+
select('#mSlider').value(m);
|
| 167 |
+
select('#nSlider').value(n);
|
| 168 |
+
|
| 169 |
+
// Clear screen to show new "Truth"
|
| 170 |
+
if(!hasCheckpoint) background(0);
|
| 171 |
}
|
| 172 |
});
|
| 173 |
+
|
| 174 |
+
// 2. BUTTONS
|
| 175 |
+
select('#morphBtn').mousePressed(() => {
|
| 176 |
isMorphing = !isMorphing;
|
| 177 |
+
toggleStyle('#morphBtn', isMorphing);
|
|
|
|
|
|
|
| 178 |
});
|
| 179 |
+
|
| 180 |
+
select('#symmetryBtn').mousePressed(() => {
|
|
|
|
| 181 |
symmetryMode = !symmetryMode;
|
| 182 |
+
toggleStyle('#symmetryBtn', symmetryMode);
|
|
|
|
|
|
|
| 183 |
});
|
| 184 |
+
|
| 185 |
+
select('#pulseBtn').mousePressed(() => {
|
|
|
|
| 186 |
pulseMode = !pulseMode;
|
| 187 |
+
toggleStyle('#pulseBtn', pulseMode);
|
|
|
|
|
|
|
| 188 |
});
|
| 189 |
|
| 190 |
+
select('#freezeBtn').mousePressed(() => {
|
| 191 |
+
// Save current view to frozen layer
|
|
|
|
|
|
|
| 192 |
frozenLayer.clear();
|
| 193 |
+
frozenLayer.image(get(), 0, 0, width, height); // Capture canvas
|
| 194 |
hasCheckpoint = true;
|
| 195 |
|
| 196 |
+
let btn = select('#freezeBtn');
|
| 197 |
+
btn.html("❄️ Saved!");
|
| 198 |
+
btn.addClass('active-btn');
|
| 199 |
+
setTimeout(() => { btn.html("❄️ Freeze Layer"); btn.removeClass('active-btn'); }, 1000);
|
| 200 |
+
});
|
| 201 |
+
|
| 202 |
+
select('#clearBtn').mousePressed(() => {
|
| 203 |
+
if (hasCheckpoint) {
|
| 204 |
+
image(frozenLayer, 0, 0, width, height); // Restore checkpoint
|
| 205 |
+
} else {
|
| 206 |
+
background(0); // Full black
|
| 207 |
+
}
|
| 208 |
});
|
| 209 |
+
|
| 210 |
+
select('#saveBtn').mousePressed(() => {
|
| 211 |
+
saveCanvas('Vers3Dynamics_Resonance', 'png');
|
| 212 |
+
});
|
| 213 |
+
|
| 214 |
+
// 3. DROPDOWN
|
| 215 |
+
select('#paletteSelect').changed(function() {
|
| 216 |
+
currentPalette = this.value();
|
| 217 |
+
});
|
| 218 |
+
|
| 219 |
+
// 4. MANUAL SLIDERS (Listeners)
|
| 220 |
+
select('#mSlider').input(function() { m = parseFloat(this.value()); });
|
| 221 |
+
select('#nSlider').input(function() { n = parseFloat(this.value()); });
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
// Helper to toggle button visual state
|
| 225 |
+
function toggleStyle(id, isActive) {
|
| 226 |
+
let el = select(id);
|
| 227 |
+
if (isActive) el.addClass('active-btn');
|
| 228 |
+
else el.removeClass('active-btn');
|
| 229 |
}
|
| 230 |
|
| 231 |
function draw() {
|
| 232 |
+
// --- LOGIC UPDATES ---
|
| 233 |
+
|
| 234 |
if (isMorphing) {
|
| 235 |
+
background(0, 0, 0, 5); // Fade trail
|
| 236 |
m += morphSpeed * 0.6;
|
| 237 |
n += morphSpeed * 0.4;
|
| 238 |
if (m > 20 || m < 1) morphSpeed *= -1;
|
| 239 |
|
| 240 |
+
// Sync sliders visually
|
| 241 |
select('#mSlider').value(m);
|
| 242 |
select('#nSlider').value(n);
|
|
|
|
|
|
|
| 243 |
}
|
| 244 |
+
|
|
|
|
| 245 |
if (pulseMode) {
|
| 246 |
pulsePhase += 0.05;
|
| 247 |
sensitivity = 0.02 + 0.015 * sin(pulsePhase);
|
| 248 |
+
} else {
|
| 249 |
+
sensitivity = 0.02; // Reset if off
|
| 250 |
}
|
| 251 |
+
|
| 252 |
hueOffset += 0.5;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
+
// --- DRAWING PARTICLES ---
|
| 255 |
+
|
| 256 |
+
// We do NOT draw the frozen layer here constantly to avoid clearing the "sand".
|
| 257 |
+
// The frozen layer sits underneath in memory until we need to restore it.
|
| 258 |
+
|
| 259 |
+
strokeWeight(1.5);
|
| 260 |
+
|
| 261 |
for (let i = 0; i < particles; i++) {
|
| 262 |
let x = random(-1, 1);
|
| 263 |
let y = random(-1, 1);
|
| 264 |
|
| 265 |
+
// Chladni Math
|
| 266 |
+
let val = cos(n * PI * x / 2) * cos(m * PI * y / 2) -
|
| 267 |
+
cos(m * PI * x / 2) * cos(n * PI * y / 2);
|
| 268 |
|
| 269 |
+
if (abs(val) < sensitivity) {
|
| 270 |
+
let sx = map(x, -1, 1, 0, width);
|
| 271 |
+
let sy = map(y, -1, 1, 0, height);
|
| 272 |
|
| 273 |
+
let col = getPaletteColor(x, y, val);
|
| 274 |
+
stroke(col);
|
| 275 |
+
point(sx, sy);
|
| 276 |
|
| 277 |
if (symmetryMode) {
|
| 278 |
+
point(width - sx, sy);
|
| 279 |
+
point(sx, height - sy);
|
| 280 |
+
point(width - sx, height - sy);
|
|
|
|
| 281 |
}
|
| 282 |
}
|
| 283 |
}
|
| 284 |
}
|
| 285 |
|
| 286 |
+
function getPaletteColor(x, y, val) {
|
| 287 |
+
let d = dist(x, y, 0, 0); // Distance from center
|
| 288 |
+
|
| 289 |
+
if (currentPalette === 'cyan') {
|
| 290 |
+
return color(180, 100, 100, 70);
|
| 291 |
+
} else if (currentPalette === 'rainbow') {
|
| 292 |
+
return color((hueOffset + d * 200) % 360, 90, 100, 60);
|
| 293 |
+
} else if (currentPalette === 'fire') {
|
| 294 |
+
let hue = map(d, 0, 1.4, 0, 60);
|
| 295 |
+
return color(hue, 100, 100, 70);
|
| 296 |
+
} else if (currentPalette === 'quantum') {
|
| 297 |
+
// Purple/Pink/Blue
|
| 298 |
+
return color(map(abs(val), 0, 0.02, 250, 320), 90, 100, 70);
|
| 299 |
}
|
| 300 |
+
return color(255);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
}
|
| 302 |
</script>
|
| 303 |
</body>
|