xxxxxxxxxx
35
//Phases of the Sun
//Created by Mirette Dahab
//February 24th, 2025
//independant work
let gradientSpeed = 0.01; // Speed of gradient animation
let gradientOffset = 10; // Offset for scrolling the gradient
let rotationSpeed = 0.07; // Speed of line rotation
let rotationAngle = 20; // Initial rotation angle
function setup() {
createCanvas(410, 410);
}
function draw() {
gradientOffset += gradientSpeed;
let t = (sin(gradientOffset) * 0.5 + 0.4); // Smoothly oscillates between 0 and 1
translate(width / 2, height / 2); // Move to the center of the canvas
// Increment the rotation angle for a liquid-like motion
rotationAngle += rotationSpeed ;
for (let i = 0; i < height; i++) {
let inter = map(i, 0, height, 0, 1);
let c = lerpColor(color('#ff1020'), color('#ff00'), (inter + t) % 1);
rotate(rotationAngle + map(i, 0, height, -PI/3 , PI)); // Rotate each line differently
stroke(c);
line(-10, i - height / 4, width/32, i - height / 4); // Draw line with rotation
}
}