File size: 1,563 Bytes
c67b039
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
let flickerRate = 40; // 40 Hz flicker rate
let angle = 0;        // For rotation
let isBright = true;  // Toggle between bright and dark states

function setup() {
  createCanvas(windowWidth, windowHeight);
  frameRate(flickerRate); // Set to 40 Hz
  rectMode(CENTER);       // Center shapes for rotation
  background(0);
}

function draw() {
  // Flicker between two states
  if (isBright) {
    background(255); // Bright background
  } else {
    background(0);   // Dark background
  }
  isBright = !isBright; // Toggle

  // Add rotating grid of shapes
  let gridSize = 80; // Size of grid cells
  translate(width / 2, height / 2); // Move to center
  rotate(angle); // Apply rotation
  angle += 0.02; // Slow rotation speed

  for (let x = -width; x < width; x += gridSize) {
    for (let y = -height; y < height; y += gridSize) {
      // Alternate colors based on flicker state and position
      if ((floor(x / gridSize) + floor(y / gridSize)) % 2 === 0) {
        fill(isBright ? 0 : 255); // Inverse of background
      } else {
        fill(isBright ? 255 : 0);
      }
      noStroke();

      // Draw rotating rectangles and circles
      push();
      translate(x, y);
      rotate(angle * 0.5); // Additional rotation for each shape
      rect(0, 0, gridSize * 0.6, gridSize * 0.6); // Square
      pop();

      // Overlay smaller flickering circles
      fill(isBright ? 255 : 0); // Opposite color for contrast
      ellipse(x, y, gridSize * 0.3); // Circle
    }
  }
}

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}