File size: 10,347 Bytes
11e59fe 7579b4c 966cc12 11e59fe e03a867 11e59fe 966cc12 7579b4c b95137d e03a867 966cc12 17d4a2e 966cc12 7579b4c 11e59fe 7579b4c 966cc12 e03a867 966cc12 11e59fe 7579b4c 11e59fe e03a867 966cc12 11e59fe b95137d 966cc12 7579b4c 11e59fe b95137d 966cc12 17d4a2e e03a867 966cc12 b95137d 11e59fe e03a867 966cc12 11e59fe 966cc12 e03a867 966cc12 11e59fe 7579b4c 11e59fe 966cc12 b95137d e03a867 17d4a2e b95137d 966cc12 17d4a2e 966cc12 b95137d 7579b4c 966cc12 7579b4c 966cc12 17d4a2e e03a867 966cc12 17d4a2e 7579b4c 17d4a2e 966cc12 e03a867 b95137d 966cc12 11e59fe 966cc12 11e59fe b95137d 966cc12 e03a867 b95137d 966cc12 11e59fe e03a867 b95137d 17d4a2e e03a867 11e59fe 966cc12 b95137d e03a867 11e59fe b95137d 966cc12 b95137d 966cc12 11e59fe 966cc12 17d4a2e 966cc12 17d4a2e 966cc12 11e59fe 966cc12 b95137d 966cc12 e03a867 966cc12 17d4a2e 966cc12 e03a867 966cc12 7579b4c 17d4a2e 7579b4c 17d4a2e 966cc12 17d4a2e 7579b4c 17d4a2e 7579b4c 17d4a2e 966cc12 11e59fe 17d4a2e 11e59fe 966cc12 b95137d 966cc12 7579b4c 966cc12 e03a867 11e59fe | 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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Vers3Dynamics Cymatics</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/addons/p5.sound.min.js"></script>
<style>
body {
margin: 0; background: #050505; color: #ccc;
font-family: 'Courier New', Courier, monospace; overflow: hidden;
display: flex; flex-direction: column; align-items: center; justify-content: center;
height: 100vh;
/* FIX 1: Prevent bouncy scrolling on mobile */
touch-action: none;
}
canvas {
border: 1px solid #333;
box-shadow: 0 0 40px rgba(0, 255, 255, 0.05);
/* FIX 2: Ensure canvas never overlaps UI on small screens */
margin-bottom: 0px;
}
#ui-layer {
position: absolute; bottom: 20px; z-index: 10;
background: rgba(0, 0, 0, 0.9); backdrop-filter: blur(5px);
padding: 15px; border-radius: 12px; border: 1px solid #333;
display: flex; flex-direction: column; gap: 10px; width: 90%; max-width: 500px;
/* FIX 3: Ensure UI handles touches nicely */
touch-action: manipulation;
}
/* --- MOBILE SPECIFIC FIXES --- */
@media (max-width: 600px) {
body {
/* Shifts the visual center UP by adding "fake" padding at the bottom */
/* This leaves room for the UI so the canvas sits higher */
padding-bottom: 250px;
box-sizing: border-box;
}
#ui-layer {
bottom: 10px;
width: 95%;
padding: 10px;
}
button {
padding: 10px 5px; /* Larger touch targets */
}
}
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
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; }
button:hover { border-color: cyan; background: #222; }
.active-btn { background: cyan; color: black; font-weight: bold; border-color: cyan; }
#physics-info {
height: 30px; font-size: 10px; color: #00ff00;
border-top: 1px solid #333; padding-top: 10px; margin-top: 5px; text-align: center;
font-family: monospace; letter-spacing: 1px;
}
input[type="text"] { background: #000; border: 1px solid #333; color: cyan; padding: 10px; width: 100%; box-sizing: border-box; border-radius: 4px; text-align: center;}
</style>
</head>
<body>
<div id="ui-layer">
<div class="row">
<button id="textModeBtn" class="active-btn">🅰️ Intention</button>
<button id="audioModeBtn">🅱️ Acoustic Injection</button>
</div>
<div id="textSection" class="row">
<input type="text" id="wordInput" placeholder="Type intention...">
</div>
<div id="audioSection" class="row" style="display:none;">
<input type="file" id="audioUpload" accept="audio/*" style="font-size:10px; color:#888;">
<button id="playBtn" disabled>▶ Play</button>
</div>
<div class="row">
<button id="physicsToggle">🛠️ Physics Sim</button>
<button id="freezeBtn">❄️ Freeze</button>
<button id="clearBtn">✨ Clear</button>
<button id="saveBtn">📸 Save</button>
</div>
<div id="physics-info">
SYSTEM READY
</div>
</div>
<script>
let m = 5, n = 7;
let particles = 3000;
let sensitivity = 0.02;
let physicsMode = false;
let currentMode = 'text';
let song, fft, isPlaying = false;
let frozenLayer, hasCheckpoint = false;
let canvasSize;
function setup() {
calculateCanvasSize();
let cnv = createCanvas(canvasSize, canvasSize);
pixelDensity(2);
colorMode(HSB, 360, 100, 100, 100);
background(0);
fft = new p5.FFT(0.8);
frozenLayer = createGraphics(width, height);
frozenLayer.colorMode(HSB, 360, 100, 100, 100);
setupButtons();
windowResized();
}
function calculateCanvasSize() {
// Desktop: 90% of smallest dimension
// Mobile: 95% of Width (fills width) OR fit within available top height
if (windowWidth < 600) {
canvasSize = min(windowWidth * 0.95, windowHeight - 300);
} else {
canvasSize = min(windowWidth, windowHeight) * 0.9;
}
}
function windowResized() {
calculateCanvasSize();
resizeCanvas(canvasSize, canvasSize);
background(0);
}
function setupButtons() {
select('#physicsToggle').mousePressed(() => {
physicsMode = !physicsMode;
let btn = select('#physicsToggle');
if(physicsMode) {
btn.addClass('active-btn');
btn.html("🛠️ Simulating...");
} else {
btn.removeClass('active-btn');
btn.html("🛠️ Physics Sim");
}
updatePhysicsText();
});
select('#wordInput').input(function() {
let word = this.value();
if(word.length === 0) return;
let v1 = 0, v2 = 0;
for (let i = 0; i < word.length; i++) {
v1 += word.charCodeAt(i); v2 += word.charCodeAt(i) * (i + 1);
}
m = map(v1 % 100, 0, 100, 2, 12);
n = map(v2 % 100, 0, 100, 2, 12);
if(!hasCheckpoint) background(0);
});
select('#textModeBtn').mousePressed(() => switchMode('text'));
select('#audioModeBtn').mousePressed(() => switchMode('audio'));
select('#audioUpload').elt.onchange = (e) => {
if(song) song.stop();
song = loadSound(e.target.files[0], () => {
select('#playBtn').removeAttribute('disabled').html("▶ Play");
select('#physics-info').html("AUDIO BUFFER LOADED");
});
};
select('#playBtn').mousePressed(() => {
if(song.isPlaying()) { song.pause(); isPlaying = false; select('#playBtn').html("▶ Play"); }
else { song.play(); isPlaying = true; select('#playBtn').html("⏸ Pause"); }
});
select('#freezeBtn').mousePressed(() => {
frozenLayer.clear();
frozenLayer.image(get(), 0, 0, width, height);
hasCheckpoint = true;
select('#freezeBtn').html("❄️ Saved");
setTimeout(() => select('#freezeBtn').html("❄️ Freeze"), 1000);
});
select('#clearBtn').mousePressed(() => {
if(hasCheckpoint) image(frozenLayer, 0, 0, width, height);
else background(0);
});
select('#saveBtn').mousePressed(() => saveCanvas('Vers3Dynamics_Blueprint', 'png'));
}
function switchMode(m) {
currentMode = m;
select('#textSection').style('display', m === 'text' ? 'flex' : 'none');
select('#audioSection').style('display', m === 'audio' ? 'flex' : 'none');
select('#textModeBtn').toggleClass('active-btn', m === 'text');
select('#audioModeBtn').toggleClass('active-btn', m === 'audio');
}
function updatePhysicsText() {
if (physicsMode) {
let traps = floor(m * n * 2);
let stability = ((m+n)/24*100).toFixed(1);
select('#physics-info').html(`LEVITATION TRAPS: ${traps} | PRESSURE: HIGH`);
} else {
select('#physics-info').html(":: VISUAL RESONANCE ENGINE ::");
}
}
function draw() {
if (currentMode === 'audio' && isPlaying) {
fft.analyze();
m = lerp(m, map(fft.getEnergy("bass"), 0, 255, 2, 10), 0.05);
n = lerp(n, map(fft.getEnergy("treble"), 0, 255, 2, 14), 0.05);
background(0, 0, 0, 15);
}
if (physicsMode) {
if (frameCount % 5 === 0) {
for(let k=0; k<10; k++) {
let px = random(width);
let py = random(height);
let lx = map(px, 0, width, -1, 1);
let ly = map(py, 0, height, -1, 1);
let pVal = cos(n * PI * lx / 2) * cos(m * PI * ly / 2) - cos(m * PI * lx / 2) * cos(n * PI * ly / 2);
if(abs(pVal) > 0.5) {
noFill(); stroke(0, 100, 100, 10); ellipse(px, py, 10 + abs(pVal)*20);
}
}
}
if (frameCount % 20 === 0) {
stroke(120, 100, 100, 40); strokeWeight(1);
let step = width/15;
for(let gx=0; gx<width; gx+=step) {
for(let gy=0; gy<height; gy+=step) {
let lx = map(gx, 0, width, -1, 1);
let ly = map(gy, 0, height, -1, 1);
let val = cos(n * PI * lx / 2) * cos(m * PI * ly / 2) - cos(m * PI * lx / 2) * cos(n * PI * ly / 2);
if(abs(val) < 0.05) {
line(gx-3, gy, gx+3, gy); line(gx, gy-3, gx, gy+3);
}
}
}
}
}
if (frameCount % 30 === 0) updatePhysicsText();
for (let i = 0; i < particles; i++) {
let x = random(-1, 1), y = random(-1, 1);
let val = cos(n * PI * x / 2) * cos(m * PI * y / 2) - cos(m * PI * x / 2) * cos(n * PI * y / 2);
if (abs(val) < sensitivity) {
let sx = map(x, -1, 1, 0, width), sy = map(y, -1, 1, 0, height);
stroke(physicsMode ? color(120, 100, 100, 90) : color((frameCount * 0.5 + dist(0,0,x,y) * 100) % 360, 80, 100, 80));
strokeWeight(1.5);
point(sx, sy);
}
}
}
</script>
</body>
</html> |