Spaces:
Paused
Paused
Fix: Particle SVG loading across browsers, increased size, fixed empty layout bug
Browse files- index.html +1 -1
- src/views/chat/chat-view.js +25 -9
index.html
CHANGED
|
@@ -52,7 +52,7 @@
|
|
| 52 |
</head>
|
| 53 |
<body class="dark-theme in-chat-view">
|
| 54 |
|
| 55 |
-
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.8.
|
| 56 |
|
| 57 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 58 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
|
|
|
| 52 |
</head>
|
| 53 |
<body class="dark-theme in-chat-view">
|
| 54 |
|
| 55 |
+
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.8.138</div>
|
| 56 |
|
| 57 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 58 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
src/views/chat/chat-view.js
CHANGED
|
@@ -3271,17 +3271,28 @@ body { margin: 0; padding: 0; background: #000; overflow: hidden; display: flex;
|
|
| 3271 |
|
| 3272 |
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
| 3273 |
const dpr = window.devicePixelRatio || 1;
|
|
|
|
| 3274 |
// We set internal resolution for 250px height
|
| 3275 |
-
|
| 3276 |
-
|
|
|
|
| 3277 |
canvas.height = 250 * dpr;
|
| 3278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3279 |
const img = new Image();
|
| 3280 |
-
const dataUrl = 'data:image/svg+xml;utf8,' + encodeURIComponent(svgString);
|
| 3281 |
|
| 3282 |
let localParticles = [];
|
| 3283 |
|
| 3284 |
img.onload = () => {
|
|
|
|
| 3285 |
const logoWidth = Math.min(canvas.width * 0.8, 400 * dpr);
|
| 3286 |
const logoHeight = logoWidth;
|
| 3287 |
|
|
@@ -3297,15 +3308,15 @@ body { margin: 0; padding: 0; background: #000; overflow: hidden; display: flex;
|
|
| 3297 |
const imgData = octx.getImageData(0, 0, offscreen.width, offscreen.height);
|
| 3298 |
const data = imgData.data;
|
| 3299 |
|
| 3300 |
-
const step =
|
| 3301 |
for (let y = 0; y < offscreen.height; y += step) {
|
| 3302 |
for (let x = 0; x < offscreen.width; x += step) {
|
| 3303 |
const index = (y * offscreen.width + x) * 4;
|
| 3304 |
const alpha = data[index + 3];
|
| 3305 |
-
if (alpha >
|
| 3306 |
|
| 3307 |
-
//
|
| 3308 |
-
const particleColor = `rgba(193, 131, 240, 0.
|
| 3309 |
|
| 3310 |
localParticles.push({
|
| 3311 |
x: x + xOffset + (Math.random() - 0.5) * 5,
|
|
@@ -3315,15 +3326,20 @@ body { margin: 0; padding: 0; background: #000; overflow: hidden; display: flex;
|
|
| 3315 |
vx: 0,
|
| 3316 |
vy: 0,
|
| 3317 |
color: particleColor,
|
| 3318 |
-
size: Math.random() * 1.5 +
|
| 3319 |
dotIndex: Math.random() * Math.PI * 2 // For wobbling
|
| 3320 |
});
|
| 3321 |
}
|
| 3322 |
}
|
| 3323 |
}
|
|
|
|
| 3324 |
this.animateLocalThemeParticles(canvas, localParticles);
|
| 3325 |
};
|
| 3326 |
-
img.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3327 |
}
|
| 3328 |
|
| 3329 |
animateLocalThemeParticles(canvas, particles) {
|
|
|
|
| 3271 |
|
| 3272 |
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
| 3273 |
const dpr = window.devicePixelRatio || 1;
|
| 3274 |
+
|
| 3275 |
// We set internal resolution for 250px height
|
| 3276 |
+
// Use parentElement.clientWidth to avoid 0 width before layout
|
| 3277 |
+
const containerWidth = parentElement.clientWidth || window.innerWidth;
|
| 3278 |
+
canvas.width = containerWidth * dpr;
|
| 3279 |
canvas.height = 250 * dpr;
|
| 3280 |
|
| 3281 |
+
// Ensure SVG has width and height attributes, otherwise drawImage may fail
|
| 3282 |
+
let safeSvg = svgString;
|
| 3283 |
+
if (!safeSvg.includes('width=')) {
|
| 3284 |
+
safeSvg = safeSvg.replace('<svg ', '<svg width="100%" height="100%" ');
|
| 3285 |
+
}
|
| 3286 |
+
|
| 3287 |
+
const svgBlob = new Blob([safeSvg], { type: 'image/svg+xml;charset=utf-8' });
|
| 3288 |
+
const url = URL.createObjectURL(svgBlob);
|
| 3289 |
+
|
| 3290 |
const img = new Image();
|
|
|
|
| 3291 |
|
| 3292 |
let localParticles = [];
|
| 3293 |
|
| 3294 |
img.onload = () => {
|
| 3295 |
+
URL.revokeObjectURL(url);
|
| 3296 |
const logoWidth = Math.min(canvas.width * 0.8, 400 * dpr);
|
| 3297 |
const logoHeight = logoWidth;
|
| 3298 |
|
|
|
|
| 3308 |
const imgData = octx.getImageData(0, 0, offscreen.width, offscreen.height);
|
| 3309 |
const data = imgData.data;
|
| 3310 |
|
| 3311 |
+
const step = 3; // Denser to catch thin lines
|
| 3312 |
for (let y = 0; y < offscreen.height; y += step) {
|
| 3313 |
for (let x = 0; x < offscreen.width; x += step) {
|
| 3314 |
const index = (y * offscreen.width + x) * 4;
|
| 3315 |
const alpha = data[index + 3];
|
| 3316 |
+
if (alpha > 30) { // Lower alpha threshold
|
| 3317 |
|
| 3318 |
+
// Purple color - made more visible
|
| 3319 |
+
const particleColor = `rgba(193, 131, 240, 0.85)`;
|
| 3320 |
|
| 3321 |
localParticles.push({
|
| 3322 |
x: x + xOffset + (Math.random() - 0.5) * 5,
|
|
|
|
| 3326 |
vx: 0,
|
| 3327 |
vy: 0,
|
| 3328 |
color: particleColor,
|
| 3329 |
+
size: (Math.random() * 1.5 + 1.5) * dpr, // Multiply by dpr so they are visible on Retina
|
| 3330 |
dotIndex: Math.random() * Math.PI * 2 // For wobbling
|
| 3331 |
});
|
| 3332 |
}
|
| 3333 |
}
|
| 3334 |
}
|
| 3335 |
+
console.log(`Generated ${localParticles.length} theme particles`);
|
| 3336 |
this.animateLocalThemeParticles(canvas, localParticles);
|
| 3337 |
};
|
| 3338 |
+
img.onerror = (e) => {
|
| 3339 |
+
console.error("Failed to load Theme SVG", e);
|
| 3340 |
+
URL.revokeObjectURL(url);
|
| 3341 |
+
};
|
| 3342 |
+
img.src = url;
|
| 3343 |
}
|
| 3344 |
|
| 3345 |
animateLocalThemeParticles(canvas, particles) {
|