let flickerRate = 40; // 40 Hz flicker rate (in frames per second) let frameDuration; // Duration of each frame in milliseconds let isBlack = true; // Toggle between black and white function setup() { createCanvas(windowWidth, windowHeight); // Full-screen canvas frameRate(flickerRate); // Set frame rate to 40 Hz frameDuration = 1000 / flickerRate; // Calculate frame duration in ms (approx 25ms for 40 Hz) background(0); // Start with black } function draw() { // Alternate between black and white each frame if (isBlack) { background(0); // Black } else { background(255); // White } isBlack = !isBlack; // Toggle state // Optional: Add a simple high-contrast pattern (checkerboard) let size = 50; // Size of checkerboard squares for (let x = 0; x < width; x += size) { for (let y = 0; y < height; y += size) { if ((floor(x / size) + floor(y / size)) % 2 === 0) { fill(isBlack ? 255 : 0); // Invert color based on flicker } else { fill(isBlack ? 0 : 255); } noStroke(); rect(x, y, size, size); } } } function windowResized() { resizeCanvas(windowWidth, windowHeight); // Adjust canvas if window size changes }