memoscan
← all memos

Memo 0x50692e2a…788f3b on Ethereum

t); node._grFontWeight = fontWeight; } if (node._grStroke) { node.removeAttribute("stroke"); node._grStroke = ""; } if (node._grStrokeWidth) { node.removeAttribute("stroke-width"); node._grStrokeWidth = ""; } if (node._grTransform !== transform) { if (transform) node.setAttribute("transform", transform); else node.removeAttribute("transform"); node._grTransform = transform; } return !isStoredSpace && grShouldGlowCell(tone, glowStyle, highlightFill, column, row, motionFrame); } function svgSetProceduralTransform(node, frame) { if (!node || node._grText === "") return; const column = node._grColumn || 0; const row = node._grRow || 0; const tone = node._grTone || 0; const proceduralOffset = grProceduralGlyphOffset(column, row, frame, tone); const tx = (node._grBaseRowOffset || 0) + (node._grCenteredOffsetX || 0) + proceduralOffset[0]; const ty = (node._grCenteredOffsetY || 0) + proceduralOffset[1]; const transform = tx || ty ? "translate(" + tx + " " + ty + ")" : ""; if (node._grTransform !== transform) { if (transform) node.setAttribute("transform", transform); else node.removeAttribute("transform"); node._grTransform = transform; } } function svgMoveProceduralCells(targetCells, frame, targetGlowCells = null) { for (let index = 0; index < targetCells.length; index += 1) { svgSetProceduralTransform(targetCells[index], frame); if (targetGlowCells?.[index]) svgSetProceduralTransform(targetGlowCells[index], frame); } } function svgToneFill(tone) { const toneKey = Math.max(0, Math.min(15, Math.round(tone * 15))); const effects = SIGNAL_RITUAL_ENGINE.visualRenderer.effects || {}; const key = String(toneKey) + ":" + (effects.asciiBrightness || 0) + ":" + (effects.asciiMidtones || 0); if (!toneFillCache[key]) toneFillCache[key] = grRgbString(grInkColor(toneKey / 15)); return toneFillCache[key]; } function svgPooledRect(layer, pool, index, x, y, width, height, fill, opacity) { let rect = pool[index]; if (!rect) { rect = document.createElementNS(svgNs, "rect"); pool[index] = rect; layer.appendChild(rect); } const next = [x, y, width, height, fill, opacity.toFixed(3)]; const prev = rect._grRect || []; if (prev[0] !== next[0]) rect.setAttribute("x", next[0]); if (prev[1] !== next[1]) rect.setAttribute("y", next[1]); if (prev[2] !== next[2]) rect.setAttribute("width", next[2]); if (prev[3] !== next[3]) rect.setAttribute("height", next[3]); if (prev[4] !== next[4]) rect.setAttribute("fill", next[4]); if (prev[5] !== next[5]) rect.setAttribute("opacity", next[5]); rect._grRect = next; } function svgHideUnusedRects(pool, used) { for (let i = used; i < pool.length; i += 1) { if (pool[i]._grRect?.[5] === "0") continue; pool[i].setAttribute("opacity", "0"); pool[i]._grRect = [...(pool[i]._grRect || [0, 0, 0, 0, "#000", "0"])]; pool[i]._grRect[5] = "0"; } } function svgRenderEffects(frame) { const effects = grEffectSettings(); const fullWidth = columns * cell; const fullHeight = rows * cell; let scanRect = 0; let staticRect = 0; const scan = (effects.badScanlines || 0) / 100; if (scan > 0) { const spacing = Math.max(2, Math.round(9 - scan * 6)) * (SMOOTH_MARKETPLACE_MODE ? 2 : 1); for (let y = 0; y < fullHeight; y += spacing) { svgPooledRect(scanlinesLayer, scanlineRects, scanRect, 0, y, fullWidth, 1, "#000", Math.min(0.32, scan * 0.7)); scanRect += 1; } for (let y = Math.floor(frame % spacing); y < fullHeight; y += spacing * 7) { svgPooledRect(scanlinesLayer, scanlineRects, scanRect, 0, y, fullWidth, 1, "#fff", Math.min(0.18, scan * 0.42)); scanRect += 1; } } svgHideUnusedRects(scanlineRects, scanRect); const staticAmount = effects.asciiStatic ? (effects.asciiStaticAmount || 0) / 100 : 0; if (staticAmount > 0) { const opacity = Math.min(0.5, staticAmount * 0.72); const fleckCap = SMOOTH_MARKETPLACE_MODE ? 160 : 520; const flecks = Math.min(fleckCap, Math.round((fullWidth * fullHeight * staticAmount) / (SMOOTH_MARKETPLACE_MODE ? 2600 : 1100))); for (let i = 0; i < flecks; i += 1) { const x = Math.floor(grSmoothRandom(i * 977 + 83, frame * 0.18) * fullWidth); const y = Math.floor(grSmoothRandom(i * 977 + 84, frame * 0.16) * fullHeight); const sizeBoost = SMOOTH_MARKETPLACE_MODE ? 2.2 : 1; const size = Math.max(1, Math.floor(sizeBoost + grSmoothRandom(i * 977 + 85, frame * 0.08) * (staticAmount * 6 * sizeBoost))); svgPooledRect(staticLayer, staticRects, staticRect, x, y, size, size, grSeeded(i * 463 + frame * 79) > 0.5 ? "#ffffff" : "#000000", opacity); staticRect += 1; } } const compression = (effects.compressionScars || 0) / 100; if (compression > 0) { const block = Math.max(8, Math.round(28 - compression * 18)); const opacity = Math.min(0.22, compression * 0.55); for (let y = 0; y < fullHeight; y += block) { for (let x = 0; x < fullWidth; x += block) { if (grSeeded(x * 17 + y * 53 + frame * 101) > compression * 0.55) continue; svgPooledRect(staticLayer, staticRects, staticRect, x, y, Math.min(block, fullWidth - x), Math.min(block, fullHeight - y), grSeeded(x * 83 + y * 29 + frame * 43) > 0.5 ? "#ffffff" : "#000000", opacity); staticRect += 1; } } } const symbolDropout = (effects.symbolDropout || 0) / 100; if (symbolDropout > 0) { const block = Math.max(2, Math.round(cell * (1 + symbolDropout * (SMOOTH_MARKETPLACE_MODE ? 2.2 : 1.6)))); const opacity = Math.min(0.65, symbolDropout * 1.25); const bg = SIGNAL_RITUAL_ENGINE.visualRenderer.background || "#08090b"; for (let y = 0; y < fullHeight; y += block) { for (let x = 0; x < fullWidth; x += block) { if (grSeeded(x * 101 + y * 307 + frame * 131) < symbolDropout * 0.16) { svgPooledRect(staticLayer, staticRects, staticRect, x, y, block, block, bg, opacity); staticRect += 1; } } } } svgHideUnusedRects(staticRects, staticRect); const vignette = (effects.vignette || 0) / 100; vignetteLayer.setAttribute("opacity", Math.min(0.55, vignette * 0.9).toFixed(3)); } function svgRender(timelineFrame) { const procedural = grProceduralMotionEnabled(); const pureProcedural = grPureProceduralEnabled(); const motionFrame = procedural ? Math.max(0, Number(timelineFrame) || 0) : grPlaybackFrame(timelineFrame); const baseTimelineFrame = pureProcedural ? motionFrame : procedural ? grBaseTimelineFrameFromMotionClock(motionFrame) : timelineFrame; const frame = pureProcedural ? motionFrame : grPlaybackFrame(baseTimelineFrame); if (CACHE_FRAME_GROUPS) { svgShowCachedFrame(frame, timelineFrame); svgRenderEffects(frame); return; } if (procedural) { const repaintEvery = Math.max(1, PROCEDURAL_MOTION_CLOCK_FPS / PROCEDURAL_REPAINT_FPS); if (motionFrame < lastProceduralPaintFrame || motionFrame - lastProceduralPaintFrame >= repaintEvery) { svgPaintCells(cells, frame, null, motionFrame); svgRenderEffects(frame); lastProceduralPaintFrame = motionFrame; } else { svgMoveProceduralCells(cells, motionFrame); } return; } svgPaintCells(cells, frame); svgRenderEffects(frame); } function svgPaintCells(targetCells, frame, targetGlowCells = null, motionFrame = frame) { const storageFrame = grPureProceduralEnabled() ? 0 : frame; let toneLines = toneLineCache[storageFrame]; if (!toneLines) { toneLines = grGeneratedToneFrame(storedToneFrames, storageFrame).split("\n"); toneLineCache[storageFrame] = toneLines; } let styleLines = styleLineCache[storageFrame]; if (!styleLines) { styleLines = grGeneratedStyleFrame(storedStyleFrames, storageFrame).split("\n"); styleLineCache[storageFrame] = styleLines; } svgComputeRowOffsets(frame); for (let row = 0; row < rows; row += 1) { const toneLine = toneLines[row] || ""; const styleLine = styleLines[row] || ""; for (let column = 0; column < columns; column += 1) { const tone = toneValueMap[toneLine[column] || "0"] ?? 0; const style = grEffectiveStyle(styleLine[column] || "0", tone); const adaptiveSpec = grAdaptiveBlockSpec(styleLines, column, row, style); const recoveredAdaptiveDenseAnchor = adaptiveSpec ? adaptiveSpec.recoveredDenseAnchor : false; const adaptiveScale = adaptiveSpec ? 1 : 1; const glyph = grEdgeGlyphFromStyle(style) || grGlyphFromTone(tone, column, row, frame); const index = row * columns + column; if (style === "1") { svgClearCell(targetCells[index]); if (targetGlowCells?.[index]) svgClearCell(targetGlowCells[index]); continue; } const shouldGlow = svgSetCell(targetCells[index], glyph, tone, style, column, row, frame, adaptiveScale, motionFrame, recoveredAdaptiveDenseAnchor, adaptiveSpec); if (targetGlowCells) { if (shouldGlow) { if (!targetGlowCells[index]) targetGlowCells[index] = svgCreateCellNode(targetGlowCells._parent, column, row); svgSetCell(targetGlowCells[index], glyph, tone, style, column, row, frame, adaptiveScale, motionFrame, recoveredAdaptiveDenseAnchor, adaptiveSpec); } else if (targetGlowCells[index]) { svgClearCell(targetGlowCells[index]); } } } } } function svgBuildCachedFrame(frame) { const group = document.createElementNS(svgNs, "g"); const glowGroup = RENDER_GLOW_ENABLED ? document.createElementNS(svgNs, "g") : null; group.setAttribute("opacity", "0"); group.style.display = "none"; if (glowGroup) { glowGroup.setAttribute("opacity", "0"); glowGroup.style.display = "none"; } const targetCells = []; const targetGlowCells = []; if (glowGroup) targetGlowCells._parent = glowGroup; createCellNodes(group, targetCells); cellsLayer.appendChild(group); if (glowGroup) glowCellsLayer.appendChild(glowGroup); svgPaintCells(targetCells, frame, glowGroup ? targetGlowCells : null); frameGroups[frame] = { group, glowGroup }; return frameGroups[frame]; } function svgShowCachedFrame(frame, timelineFrame) { const entry = frameGroups[frame] || svgBuildCachedFrame(frame); if (activeFrameGroup && activeFrameGroup !== entry) { activeFrameGroup.group.style.display = "none"; activeFrameGroup.group.setAttribute("opacity", "0"); if (activeFrameGroup.glowGroup) { activeFrameGroup.glowGroup.style.display = "none"; activeFrameGroup.glowGroup.setAttribute("opacity", "0"); } } entry.group.style.display = "block"; entry.group.setAttribute("opacity", "1"); if (entry.glowGroup) { entry.glowGroup.style.display = "block"; entry.glowGroup.setAttribute("opacity", "1"); } activeFrameGroup = entry; svgQueueWarmFrame(grPlaybackFrame((timelineFrame + 1) % grTimelineFrameCount())); } function svgQueueWarmFrame(frame) { if (!CACHE_FRAME_GROUPS) return; if (frameGroups[frame] || warmingFrames.has(frame)) return; warmingFrames.add(frame); const build = () => { svgBuildCachedFrame(frame); warmingFrames.delete(frame); }; if (typeof requestIdleCallback === "function") requestIdleCallback(build, { timeout: 120 }); else setTimeout(build, 1); } function svgPrebuildCachedFrames() { if (!CACHE_FRAME_GROUPS) return; svgBuildCachedFrame(0); svgQueueWarmFrame(grPlaybackFrame(1 % grTimelineFrameCount())); } function svgStart() { const fps = Math.max(1, SIGNAL_RITUAL_ENGINE.fps || 12); const frameMs = 1000 / fps; const proceduralFrameMs = 1000 / PROCEDURAL_RENDER_FPS; let lastTime = 0; let startTime = 0; function next(now) { if (document.hidden) { lastTime = now; requestAnimationFrame(next); return; } if (!lastTime) lastTime = now; if (!startTime) startTime = now; const elapsed = now - lastTime; if (grProceduralMotionEnabled() && elapsed >= proceduralFrameMs) { tick = ((now - startTime) /