xxxxxxxxxx
47
const numLines = 190;
const radius = 200;
// Set the speed and amplitude of the line oscillation
const oscillationSpeed = 0.1;
const oscillationAmplitude = 5;
function setup() {
createCanvas(windowWidth, windowHeight);
strokeWeight(2);
// Set the frame rate
frameRate(60);
textAlign(CENTER, CENTER);
}
function draw() {
// Clear the canvas
clear();
background(250);
translate(width/2, height/2);
textFont('Helvetica');
textSize(15);
stroke(20);
fill(0);
text('Sea', 0, 0);
text(' Levels', 0, 15);
// Loop through the lines
for (let i = 0; i < numLines; i++) {
let angle = TWO_PI * i / numLines;
// Calculate the x and y components of the line end point
let x = radius * cos(angle);
let y = radius * sin(angle);
// Calculate the length of the line
let lineLength = radius + oscillationAmplitude * sin(frameCount/2 * oscillationSpeed + angle * i);
stroke(138, 196, 255);
// circle(radius * cos(angle)/4,radius *sin(angle)/4,2)
line(radius * cos(angle)/4, radius *sin(angle)/4, x * lineLength / radius, y * lineLength /radius);
stroke(230, 190, 145);
line((radius+30) * cos(angle), (radius+30) * sin(angle), x * lineLength / (radius-10), y * lineLength / (radius-10));
}
}