Here's a thinking process that leads to the suggested HTML application:
-
Analyze the Request:
- User Role: Code expert, Front-end engineer, Visual Designer with a taste for Neo-Brutalism & Y2K aesthetics.
- Goal: Engineer a "story-driven release note generator" aligning persona narratives, feature highlights, and interactive demos.
- Core Requirements: Interactive 2D tool, single file HTML, no frameworks (except Tailwind/GSAP/Canva allowed by the persona), specific design principles (Raw Typography, Hard Borders, Clashing Colors, Unpolished Look, Glitch, Marquee, etc.).
-
Deconstruct the "Story-Driven Release Note Generator":
- What is it? A tool that takes input (features, release name, persona) and outputs a visually engaging, narrative-style release note page (or a preview of it) that feels like a story rather than a bulleted list.
- Interactivity: Users should be able to select different "personas" (which dictate color/tone/voice), enter feature details, add "demos" (simulated), and generate the visual output.
- Output: The generated release note itself should be designed according to the Neo-Brutalism/Y2K principles.
-
Visual Style Strategy (The "Look"):
- Palette: Acid green, hot pink, bright yellow, cyan, stark white/black.
- Borders: Thick, solid black (3px-5px), maybe some offset shadows (hard drops).
- Typography: Monospace (Courier) for data/code, Display/Huge fonts for titles (Times New Roman mixed with Impact/Arial Black). Overflows are mandatory.
- Layout: Asymmetric, collage-like, uses
position: absolute heavily, CSS Grid for chaos.
- Animations: Glitch effects (CSS clip-path), marquees, hard steps (not smooth).
- "Unpolished": Rough edges, default cursors, UI controls shouldn't look like Bootstrap; they should look like retro OS buttons (Win95 style but more brutal).
-
Functional Workflow (The "Brain"):
- Input Section (Left/Top):
- Product Name input.
- Version number.
- Release Date.
- Feature List (dynamic add/remove). Each feature has: Title, Description, Impact (High/Med/Low), and maybe a "Demo Type" (Glitch/Matrix/Binary).
- Persona Selector: "Cyberpunk", "Y2K Pop", "Retro Tech", "Brutalist". These change the color theme of the preview.
- Action: "GENERATE CHAOS" button.
- Output Section (Main Area): A "canvas" that renders the release note page.
- Preview Interaction: The output should be scrollable and interactive. Buttons inside the preview might trigger mini-animations (e.g., clicking a "Demo" button runs a specific CSS glitch or JS canvas effect).
-
Technical Implementation Steps:
- Setup: HTML5 skeleton, import Tailwind CSS (CDN), GSAP (CDN).
- Styles: Custom CSS for raw elements (blink, marquee), glitch keyframes, custom scrollbars. Tailwind config for arbitrary values (borders, colors).
- Layout: Split screen: Controls sidebar + Preview canvas.
- State Management: Simple vanilla JS object to hold data (
productInfo, features). Functions to render the control panel and the preview.
- Rendering Logic:
- Generate HTML string or DOM elements for the preview based on the selected persona.
- Apply specific classes for themes (e.g.,
bg-acid-green, border-black).
- Insert "Story Elements": Big intro text, dramatic feature cards.
- Implement "Interactive Demos": Small JS snippets injected or toggled. E.g., a "Matrix" rain canvas, a "Glitch" text scrambler.
-
Refining the Design (Applying Persona Constraints):
- Marquee: A running text at the top or bottom of the generated page. "NEW UPDATE!! SYSTEM READY!!".
- Hard Borders:
border-4 border-black.
- Typography:
text-[8rem] leading-none font-serif uppercase.
- Glitch: CSS class
.glitch with ::before and ::after.
-
Drafting the Code (Mental or Scratchpad):
- HTML Structure:
<body class="bg-black text-white overflow-x-hidden">
<div id="app-container" class="flex h-screen">
<!-- Sidebar Controls -->
<aside class="w-1/3 bg-gray-900 p-4 border-r-4 border-white overflow-y-auto">...</aside>
<!-- Preview Area -->
<main class="flex-1 relative bg-white overflow-auto">...</main>
</div>
</body>
- Theme Config:
const themes = {
cyberpunk: { primary: '#00ff41', secondary: '#ff0055', bg: '#111', titleFont: 'Impact' },
y2k: { primary: '#ffb7c5', secondary: '#00ffff', bg: '#fff0e6', titleFont: 'Comic Sans MS' },
// ...
}
- Feature Rendering:
Loop through features array. Create a div. Inside: Huge number (01, 02), Huge Title, Paragraph, and a "LAUNCH DEMO" button that triggers a modal or inline animation.
-
Adding "Story" Elements:
- The release notes shouldn't just list features. They need an intro paragraph that sounds epic ("The dawn of a new era...").
- Use fill-in-the-blank logic or procedural generation based on the product name to make the intro dynamic.
-
Implementing "Interactive Demos" (The tricky part without external assets):
- Glitch Demo: A canvas that draws random rectangles.
-
- ASCII Demo:* A canvas converting text to ASCII.
- Vignette Demo: A pulsing radial gradient.
- These will be placed inside the preview when the user clicks the "Play Demo" button for a feature.
-
Polishing the "Chaos":
- Add noise texture overlay (CSS background-image with base64 noise or repeating linear gradient).
- Make sure the generated preview looks like a standalone website but within the container.
- Ensure the glitch effect is selectable: A text element that scrambles on hover.
-
Self-Correction/Review during thought process:
- Issue: Tailwind via CDN is large, might be slow. Fix: It's acceptable for a single file demo. Use JIT mode (standard CDN).
- Refinement: The user wants "story-driven." I need to ensure the narrative flow is prominent. Large block quotes, separated by thin lines.
- Constraint Check: No external frameworks besides Tailwind/GSAP. Use GSAP for the "hard" animations of the preview elements entering. Use
SteppedEase for that retro digital stop-motion feel.
-
Final Code Structure Assembly:
<!DOCTYPE html>
<head>: Tailwind CDN, GSAP CDN, Custom <style> for marquee, raw cursor, glitch specifics.
<body>:
- App Layout.
- Script: Define themes, feature data, render functions, event listeners.
- Logic to handle "Add Feature", "Delete Feature", "Theme Change".
- Logic to generate the main preview DOM.
- Logic to handle "Demo" clicks inside the preview (scoping events).
-
Final Polish:
- Ensure all text is as requested (English).
- Check contrast (Neo-Brutalism requires high contrast).
- Verify no
alert().
- Add comments explaining the "Design Principles" implementation.
(Self-Correction during coding the specific "Story" aspect):
I need a "Narrative Arc" in the preview. It should be:
- Header: Massive title.
- Banner: Marquee.
- Intro: The "Context" - what problem does this solve?
- Feature 1, Feature 2... with embedded "Simulations".
- Footer: Retro copyright.
Let's implement this.
(Detailed Code Plan)
- Themes: Force (Black/White/Red), Acid (Green/Pink), Y2K (Blue/Pink/Yellow).
- Controls: Use raw HTML inputs with thick borders (
border-2).
- GSAP: Use
gsap.from(".neo-element", { duration: 0.2, x: -10, opacity: 0, ease: "steps(5)" }) on generation.
Let's write the code.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>NEO-RELEASE // GENERATOR</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- GSAP for staccato animations -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script>
tailwind.config = {
theme: {
extend: {
colors: {
acid: '#ccff00',
hot: '#ff0055',
cyb: '#00f0ff',
mono: '#1a1a1a',
paper: '#f4f4f0'
},
border: {
'4': '4px',
},
boxShadow: {
'hard': '4px 4px 0px 0px #000',
'hard-hover': '6px 6px 0px 0px #000',
},
fontFamily: {
'raw': ['"Courier New"', 'Courier', 'monospace'],
'display': ['"Times New Roman"', 'Times', 'serif'],
'impact': ['Impact', 'sans-serif']
}
}
}
}
</script>
<style>
/* RAW UNPOLISHED STYLES */
body {
cursor: crosshair;
overflow: hidden;
}
/* The "Scratch card" texture */
.noise-bg {
background-image: radial-gradient(#000 1px, transparent 1px);
background-size: 10px 10px;
opacity: 0.1;
}
/* Glitch effect definition */
.glitch-wrapper {
position: relative;
}
.glitch-wrapper::before,
.glitch-wrapper::after {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.glitch-wrapper:hover::before {
left: 2px;
text-shadow: -2px 0 #ff0055;
clip-path: inset(20% 0 30% 0);
animation: glitch-anim-1 2s infinite linear alternate-reverse;
}
.glitch-wrapper:hover::after {
left: -2px;
text-shadow: -2px 0 #00f0ff;
clip-path: inset(60% 0 10% 0);
animation: glitch-anim-2 2s infinite linear alternate-reverse;
}
@keyframes glitch-anim-1 {
0% { clip-path: inset(20% 0 30% 0); }
20% { clip-path: inset(10% 0 80% 0); }
40% { clip-path: inset(80% 0 5% 0); }
60% { clip-path: inset(30% 0 40% 0); }
80% { clip-path: inset(10% 0 70% 0); }
100% { clip-path: inset(60% 0 20% 0); }
}
@keyframes glitch-anim-2 {
0% { clip-path: inset(10% 0 60% 0); }
20% { clip-path: inset(30% 0 10% 0); }
40% { clip-path: inset(70% 0 20% 0); }
60% { clip-path: inset(20% 0 50% 0); }
80% { clip-path: inset(50% 0 30% 0); }
100% { clip-path: inset(0% 0 90% 0); }
}
/* Marque Text */
.marquee-container {
overflow: hidden;
white-space: nowrap;
position: relative;
}
.marquee-content {
display: inline-block;
animation: marquee 20s linear infinite;
}
@keyframes marquee {
0% { transform: translateX(100vw); }
100% { transform: translateX(-100%); }
}
/* CRT Scanline Overlay effect */
.crt-overlay {
background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
background-size: 100% 2px, 3px 100%;
pointer-events: none;
}
/* Custom Scrollbar - Win95ish */
::-webkit-scrollbar {
width: 16px;
background: #c0c0c0;
border: 2px solid #000;
}
::-webkit-scrollbar-thumb {
background: #000;
border: 2px solid #fff;
}
::-webkit-scrollbar-button {
background: #c0c0c0;
border: 2px solid #000;
height: 16px;
width: 16px;
}
</style>
</head>
<body class="font-raw bg-mono text-white h-screen w-screen flex border-t-4 border-b-4 border-black">
<!-- LEFT: CONTROLS -->
<aside class="w-[400px] bg-white text-black border-r-4 border-black flex flex-col z-20 relative">
<div class="p-6 border-b-4 border-black bg-acid text-black font-impact">
<h1 class="text-4xl mb-2">NEO-GEN</h1>
<p class="text-sm uppercase">• Story-Driven Release Engine</p>
</div>
<div class="flex-1 overflow-y-auto p-6 space-y-8 bg-paper noise-bg">
<!-- Product Info -->
<section class="space-y-3">
<label class="font-bold text-sm uppercase border-b-2 border-black">Core Identity</label>
<input type="text" id="prodName" placeholder="PROJECT NAME" class="w-full p-2 border-2 border-black font-mono bg-white focus:bg-acid focus:outline-none transition-colors">
<input type="text" id="prodVer" placeholder="VERSION (e.g. v8.0)" class="w-full p-2 border-2 border-black font-mono bg-white focus:bg-acid focus:outline-none transition-colors">
</section>
<!-- Theme Selector -->
<section class="space-y-3">
<label class="font-bold text-sm uppercase border-b-2 border-black">Persona Aesthetic</label>
<div class="grid grid-cols-2 gap-2">
<button onclick="setTheme('brutal')" class="theme-btn border-2 border-black bg-black text-white p-2 font-bold hover:bg-white hover:text-black transition-colors active">BRUTAL</button>
<button onclick="setTheme('y2k')" class="theme-btn border-2 border-black bg-pink-500 text-white p-2 font-bold hover:bg-white hover:text-black transition-colors">Y2K</button>
<button onclick="setTheme('cyber')" class="theme-btn border-2 border-black bg-cyan-500 text-white p-2 font-bold hover:bg-white hover:text-black transition-colors">CYBER</button>
<button onclick="setTheme('acid')" class="theme-btn border-2 border-black bg-acid text-black p-2 font-bold hover:bg-white transition-colors">ACID</button>
</div>
</section>
<!-- Features Editor -->
<section class="space-y-3">
<div class="flex justify-between items-center border-b-2 border-black">
<label class="font-bold text-sm uppercase">Feature Nodes</label>
<button onclick="addFeature()" class="bg-black text-white border border-white px-2 text-xs hover:bg-white hover:text-black">+ ADD</button>
</div>
<div id="featureList" class="space-y-4">
<!-- Features injected here -->
</div>
</section>
<!-- Generate -->
<div class="pt-4">
<button onclick="generateRelease()" class="w-full py-4 bg-hot text-white font-impact text-2xl border-4 border-black shadow-hard hover:shadow-hard-hover active:translate-x-1 active:translate-y-1 transition-all">
COMPILE STORY
</button>
</div>
<footer class="text-xs font-mono text-gray-500 text-center">
System Status: <span class="animate-pulse text-red-600">ONLINE</span><br>
v1.0.4 // NO COPYRIGHT INTENDED
</footer>
</div>
</aside>
<!-- RIGHT: PREVIEW CANVAS -->
<main class="flex-1 relative bg-white overflow-hidden flex flex-col">
<div class="absolute top-4 right-4 z-30 bg-black text-white text-xs px-2 py-1 font-mono hidden print:block">
PREVIEW MODE // SANDBOX
</div>
<!-- THE GENERATED CONTENT LIVES HERE -->
<div id="preview-container" class="flex-1 overflow-y-auto p-4 md:p-12 relative crt-overlay">
<!-- Output generated via JS -->
<div id="generated-output" class="max-w-3xl mx-auto min-h-full">
<div class="text-center mt-40 border-b-8 border-black pb-10">
<p class="text-mono text-sm mb-2">SYSTEM UPDATE READY</p>
<h2 class="text-8xl font-impact leading-none uppercase mb-6 tracking-tighter">GENERATE YOUR <br><span class="text-acid">NARRATIVE</span></h2>
<p class="font-mono text-lg italic">"Input data on the left to begin the sequence."</p>
</div>
</div>
</div>
</main>
<!-- TEMPLATE HIDDEN FOR REFERENCE (Not used) -->
<script>
// --- STATE ---
let currentTheme = 'brutal';
let features = [
{ title: "NEURAL LINK", desc: "Direct brain-to-computer interface now works with Windows 95.", demoType: "glitch" },
{ title: "ACID GRID", desc: "The UI grid now melts under pressure.", demoType: "matrix" }
];
// --- THEME CONFIGS ---
const themes = {
brutal: { name: 'BRUTAL', bg: '#f4f4f0', text: '#000', accent: '#000', border: '#000', primary: '#000', secondary: '#fff', font: 'Impact' },
y2k: { name: 'Y2K', bg: '#ffb7c5', text: '#2a2a2a', accent: '#00ffff', border: '#000', primary: '#ff1493', secondary: '#00ff00', font: 'Comic Sans MS' }, // intentionally ugly
cyber: { name: 'CYBER', bg: '#050505', text: '#00ff41', accent: '#00f0ff', border: '#00ff41', primary: '#00ff41', secondary: '#ff0055', font: 'Courier New' },
acid: { name: 'ACID', bg: '#ccff00', text: '#330000', accent: '#ff00ff', border: '#330000', primary: '#330000', secondary: '#0000ff', font: 'Times New Roman' }
};
// --- DOM ELEMENTS ---
const featureListEl = document.getElementById('featureList');
const outputEl = document.getElementById('generated-output');
const prodNameInput = document.getElementById('prodName');
const prodVerInput = document.getElementById('prodVer');
// --- INITIALIZATION ---
function init() {
renderFeatureControls();
// Add a glitch animation on load
gsap.from("h1", { y: -50, opacity: 0, duration: 1, ease: "bounce.out" });
}
// --- FEATURE CONTROL RENDERER (Left Side) ---
function renderFeatureControls() {
featureListEl.innerHTML = '';
features.forEach((feat, index) => {
const div = document.createElement('div');
div.className = 'bg-white border-2 border-black p-3 shadow-2 relative group';
div.innerHTML = `
<div class="absolute -right-2 -top-2 bg-black text-white text-xs font-bold w-6 h-6 flex items-center justify-center cursor-pointer" onclick="removeFeature(${index})">X</div>
<input type="text" value="${feat.title}" onchange="updateFeature(${index}, 'title', this.value)" placeholder="FEATURE TITLE" class="w-full font-bold border-b border-black bg-transparent mb-2 focus:outline-none focus:border-acid">
<textarea onchange="updateFeature(${index}, 'desc', this.value)" placeholder="DESCRIPTION..." class="w-full h-16 text-sm font-mono resize-none border border-black p-1 bg-gray-50 focus:bg-acid focus:outline-none">${feat.desc}</textarea>
<div class="mt-2">
<label class="text-xs font-mono">DEMO TYPE:</label>
<select onchange="updateFeature(${index}, 'demoType', this.value)" class="text-xs border border-black bg-white">
<option value="glitch" ${feat.demoType === 'glitch' ? 'selected' : ''}>GLITCH</option>
<option value="matrix" ${feat.demoType === 'matrix' ? 'selected' : ''}>MATRIX</option>
<option value="vhs" ${feat.demoType === 'vhs' ? 'selected' : ''}>VHS STATIC</option>
<option value="none" ${feat.demoType === 'none' ? 'selected' : ''}>NONE</option>
</select>
</div>
`;
featureListEl.appendChild(div);
});
}
function addFeature() {
features.push({ title: "NEW FEATURE", desc: "Enter description here...", demoType: "glitch" });
renderFeatureControls();
}
function removeFeature(index) {
if(features.length > 1) {
features.splice(index, 1);
renderFeatureControls();
}
}
function updateFeature(index, key, value) {
features[index][key] = value;
}
function setTheme(themeName) {
currentTheme = themeName;
// Update UI buttons active state
document.querySelectorAll('.theme-btn').forEach(btn => btn.classList.remove('border-4', 'ring-2'));
event.target.classList.add('border-4', 'ring-2');
}
// --- GENERATOR LOGIC (The Main Output) ---
function generateRelease() {
const theme = themes[currentTheme];
const name = prodNameInput.value || "PROJECT X";
const version = prodVerInput.value || "v1.0.0";
const date = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
// 1. Construct the Header
let html = `
<div class="relative overflow-hidden py-10 border-b-8 border-${theme.border} mb-12" style="background: linear-gradient(135deg, ${theme.bg}, ${adjustColor(theme.bg, 20)})">
<!-- Noise Overlay -->
<div class="absolute inset-0 pointer-events-none opacity-10" style="background-image: url('data:image/svg+xml,%3Csvg viewBox=%220 0 200 200%22 xmlns=%22http://www.w3.org/2000/svg%22%3E%3Cfilter id=%22noise%22%3E%3CfeTurbulence type=%22fractalNoise%22 baseFrequency=%220.65%22 numOctaves=%223%22 stitchTiles=%22stitch%22/%3E%3C/filter%3E%3Crect width=%22100%25%22 height=%22100%25%22 filter=%22url(%23noise)%22 opacity=%221%22/%3E%3C/svg%3E');"></div>
<div class="container mx-auto px-4 text-center relative z-10">
<div class="marquee-container mb-6 border-4 border-black bg-${theme.primary} text-${theme.text} py-2 font-bold uppercase">
<div class="marquee-content text-sm">
SYSTEM UPDATE // ${version} // DEPLOYED // ${name.toUpperCase()} // SYSTEM UPDATE // ${version} // DEPLOYED // ${name.toUpperCase()} // SYSTEM UPDATE // ${version} // DEPLOYED // ${name.toUpperCase()} //
</div>
</div>
<h1 class="text-6xl md:text-9xl font-${theme.font} leading-none uppercase tracking-tighter mb-4" style="color: ${theme.text}; text-shadow: 4px 4px 0px ${theme.secondary}">
${name}
</h1>
<p class="text-2xl font-mono border-t-2 border-${theme.border} border-b-2 border-${theme.border} inline-block py-2 px-4 bg-${theme.accent} text-${theme.text}">
RELEASE CANDIDATE // ${date}
</p>
</div>
</div>
<!-- Narrative Opening -->
<div class="container mx-auto px-4 py-10 font-serif text-2xl md:text-3xl" style="color: ${theme.text}">
<p class="mb-8 border-l-8 border-${theme.accent} pl-6 text-justify">
_IT IS TIME. The architecture of the old world crumbles under the weight of its own perfectionism. We present <strong>${name}</strong>—not an update, but a <span style="text-decoration: underline wavy ${theme.secondary} 3px;">visceral</span> reimagining of what software can feel like. This release dismantles the mundane and replaces it with raw, unfiltered power.
</p>
</div>
`;
// 2. Construct Feature List with Demos
html += `<div class="container mx-auto px-4 pb-20 space-y-24">`;
features.forEach((feat, idx) => {
const num = (idx + 1).toString().padStart(2, '0');
// HTML for the feature block
html += `
<section id="feat-${idx}" class="relative scroll-mt-20">
<span class="absolute -left-4 top-0 text-[10rem] font-mono text-gray-200 opacity-50 select-none" style="z-index: -1;">${num}</span>
<div class="flex flex-col md:flex-row gap-6 items-start">
<!-- Title Area -->
<div class="flex-1">
<h2 class="text-4xl md:text-6xl font-${theme.font} uppercase mb-4 leading-none border-b-4 border-${theme.accent} pb-2 inline-block" style="color: ${theme.text}">
${feat.title}
</h2>
<p class="font-mono text-lg mt-4 p-4 border-2 border-black bg-gray-100 shadow-hard">
> DESCRIPTION: ${feat.desc}
</p>
</div>
</div>
<!-- Interactive Demo Container -->
${feat.demoType !== 'none' ? `
<div class="mt-8 group">
<div class="flex items-center gap-2 mb-2 cursor-pointer" onclick="toggleDemo(${idx})">
<span class="bg-black text-white px-2 py-1 font-mono text-xs border border-white">[ INVOKE DEMO ]</span>
<span class="text-sm font-bold font-mono uppercase italic hover:underline decoration-4">Initializing ${feat.demoType} protocol...</span>
</div>
<div id="demo-box-${idx}" class="hidden border-4 border-black bg-black p-2 relative overflow-hidden h-64 w-full">
<canvas id="canvas-${idx}" class="w-full h-full block"></canvas>
<div class="absolute bottom-2 right-2 text-white font-mono text-[10px]">LIVE RENDER</div>
</div>
</div>
` : ''}
<div class="mt-6 border-t-2 border-dashed border-gray-400"></div>
</section>
`;
});
html += `</div>`; // End Container
// 3. Footer
html += `
<footer class="border-t-4 border-black bg-${theme.bg} py-12 text-center font-mono">
<p class="uppercase mb-2">End of Transmission</p>
<p class="text-sm opacity-60">© ${new Date().getFullYear()} NEO-SOFTWORKS // BUILT BY THE COMMUNITY // DESTROY TO REBUILD</p>
<div class="mt-4 inline-block border-2 border-black px-4 py-2 transform rotate-1 hover:rotate-0 transition-transform duration-200">
<code style="color: ${theme.accent}">> RUN SYSTEM CHECK</code>
</div>
</footer>
`;
// Render HTML
outputEl.innerHTML = html;
// Apply GSAP Animations (Staccato)
const elems = outputEl.querySelectorAll('section, h1, p');
gsap.from(elems, {
duration: 0.4,
y: 20,
opacity: 0,
stagger: 0.1,
ease: "steps(4)"
});
// Update theme of preview container
outputEl.className = `max-w-4xl mx-auto min-h-full font-raw text-${currentTheme === 'cyber' ? 'black' : 'black'}`; // Reset basic font
}
// --- INTERACTIVE DEMOS ---
let demosRunning = {};
window.toggleDemo = function(index) {
const box = document.getElementById(`demo-box-${index}`);
const canvas = document.getElementById(`canvas-${index}`);
const type = features[index].demoType;
if (box.classList.contains('hidden')) {
box.classList.remove('hidden');
// Resize canvas resolution
canvas.width = canvas.offsetWidth;
canvas.height = canvas.offsetHeight;
startDemo(canvas, type, index);
} else {
box.classList.add('hidden');
stopDemo(index);
}
};
function startDemo(canvas, type, idx) {
if(demosRunning[idx]) cancelAnimationFrame(demosRunning[idx]);
const ctx = canvas.getContext('2d');
const w = canvas.width;
const h = canvas.height;
demosRunning[idx] = true;
if (type === 'matrix') {
const cols = Math.floor(w / 14);
const drops = Array(cols).fill(1);
function matrix() {
if(!demosRunning[idx]) return;
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, w, h);
ctx.fillStyle = '#0f0';
ctx.font = '15px monospace';
for (let i = 0; i < drops.length; i++) {
const text = String.fromCharCode(Math.random() * 128);
ctx.fillText(text, i * 14, drops[i] * 15);
if (drops[i] * 15 > h && Math.random() > 0.975) drops[i] = 0;
drops[i]++;
}
demosRunning[idx] = requestAnimationFrame(matrix);
}
matrix();
} else if (type === 'glitch') {
let offset = 0;
function glitch() {
if(!demosRunning[idx]) return;
const color = currentTheme === 'cyber' ? '#00ff41' : '#ff0055';
ctx.fillStyle = '#000';
ctx.fillRect(0,0,w,h);
// Draw random rectangles
for(let i=0; i<50; i++) {
ctx.fillStyle = Math.random() > 0.5 ? color : '#fff';
ctx.fillRect(
Math.random() * w,
Math.random() * h,
Math.random() * 100,
Math.random() * 20
);
}
// Draw slice
const sliceY = Math.random() * h;
const sliceH = Math.random() * 50;
try { ctx.drawImage(canvas, offset, sliceY, w, sliceH, 0, sliceY, w, sliceH); } catch(e){}
offset = (offset + 10) % w;
demosRunning[idx] = requestAnimationFrame(glitch);
}
glitch();
} else if (type === 'vhs') {
let frame = 0;
function vhs() {
if(!demosRunning[idx]) return;
ctx.fillStyle = `hsl(0, 0%, ${10 + Math.random()*20}%)`;
ctx.fillRect(0,0,w,h);
// Scanlines
ctx.fillStyle = 'rgba(0,0,0,0.3)';
for(let i=0; i<h; i+=4) ctx.fillRect(0,i,w,2);
// Static text
ctx.fillStyle = '#fff';
ctx.font = '20px Courier New';
ctx.fillText(`FRAME: ${frame} // SIGNAL: ${Math.random() > 0.3 ? 'LOCKED' : 'LOST'}`, 10, 20);
// Color drift
ctx.globalCompositeOperation = 'difference';
ctx.fillStyle = '#f0f';
ctx.fillRect(Math.random()*w, 0, Math.random()*100, h);
frame++;
demosRunning[idx] = requestAnimationFrame(vhs);
}
vhs();
}
}
function stopDemo(index) {
demosRunning[index] = false;
}
function adjustColor(color, amount) {
// very basic color lightener/darkener for gradient purposes
return color;
}
// --- INIT ---
window.addEventListener('DOMContentLoaded', init);
// Initial auto-gen for demo purposes
setTimeout(generateRelease, 500);
</script>
</body>
</html>