Day 10 - Art 1

You can only use TAU in your code, no other number allowed

Sinusoidal Spiral Dance

This generative art piece creates a mesmerizing spiral pattern of constantly oscillating shapes, where the radius of each shape varies sinusoidally over time. The hues shift dynamically, creating a vibrant, colorful composition. The shapes themselves are intricate polygons with vertices that move in a sine wave motion, creating a fluid, swirling effect. As time progresses, the movement and color evolve, resulting in a hypnotic and ever-changing visual experience.

// Variable to control time progression
let t = 0;
let canvas;

// Setup function is called once when the program starts
function setup() {
  // Create the canvas with size based on TAU (circle constant, ~6.28) cubed
  canvas = createCanvas(TAU * TAU * TAU, TAU * TAU * TAU);
  canvas.parent('canvas-container');
  
  // Set color mode to HSB (Hue, Saturation, Brightness) with TAU as the maximum value for hue
  colorMode(HSB, TAU);
  
  // Disable filling of shapes
  noFill();
  
  // Set the frame rate based on the value of TAU (a large value)
  frameRate(TAU * TAU / TAU); // This effectively sets the frame rate to TAU (~6.28)
}

// Draw function is continuously called to render the animation
function draw() {
  // Set the background color (black) with some variation using TAU
  background(0, TAU / TAU * TAU / TAU / TAU);
  
  // Move the origin to the center of the canvas
  translate(width / (TAU / TAU + TAU / TAU), height / (TAU / TAU + TAU / TAU));

  // Define the number of shapes based on the value of TAU (circle constant)
  let numShapes = TAU * (TAU / (TAU / TAU + TAU / TAU));
  
  // Maximum radius of the shapes, depending on the height of the canvas
  let maxRadius = height / (TAU / (TAU / TAU + TAU / TAU + TAU / TAU));
  
  // Time offset based on the global variable 't' and some adjustments using TAU
  let timeOffset = t * (TAU / (TAU * (TAU / (TAU + TAU))));

  // Loop to create multiple shapes based on the calculated number of shapes
  for (let i = 0; i < numShapes; i += TAU / (TAU / (TAU + TAU))) {
    
    // Calculate radius for each shape based on a sinusoidal function
    let radius = maxRadius * (TAU / (TAU + TAU) + sin(i + timeOffset)) / (TAU / (TAU + TAU));
    
    // Hue value is based on the current iteration and the time offset, ensuring color variation
    let hue = (i + timeOffset) % TAU;
    
    // Set stroke color (hue, saturation, brightness)
    stroke(hue, TAU, TAU);
    
    // Set stroke weight for the shape outline
    strokeWeight(TAU / (TAU + TAU + TAU + TAU));

    // Begin a new shape (polygon)
    beginShape();
    
    // Loop to create vertices for each shape (circle-like shape with an additional oscillation)
    for (let angle = 0; angle < TAU; angle += TAU / (TAU * (TAU / (TAU + TAU)))) {
      
      // Calculate the x and y positions of each vertex with sinusoidal variations
      let x = cos(angle) * radius + sin(angle * (TAU / (TAU + TAU)) + timeOffset) * (TAU * (TAU / (TAU / TAU))); 
      let y = sin(angle) * radius + cos(angle * (TAU / (TAU / (TAU / (TAU + TAU)))) - timeOffset) * (TAU * (TAU / (TAU + TAU + TAU / TAU)));

      // Add the vertex to the shape
      vertex(x, y);
    }
    
    // Close the shape (complete the polygon)
    endShape(CLOSE);
  }

  // Increment time variable 't' to create dynamic changes in the pattern over time
  t += TAU / (TAU * (TAU / (TAU + TAU)));
}