File size: 1,214 Bytes
14a3228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
}