xxxxxxxxxx
let noiseOffsetX, noiseOffsetY; // Offsets for Perlin noise
let angle = 0; // Angle for cyclic motion
let radius = 50; // Radius of the agent
let speed = 0.02; // Speed of cyclic motion
let colorOffset = 0; // Offset for color changes
function setup() {
createCanvas(600, 600); // Canvas size
noiseOffsetX = random(1000); // Initialize Perlin noise offset
noiseOffsetY = random(1000);
noStroke(); // Remove border for shapes
}
function draw() {
background(20, 50, 70, 25); // Semi-transparent background for trail effect
// Calculate position using cyclic and noise-based motion
let x = width / 2 + cos(angle) * 200 + map(noise(noiseOffsetX), 0, 1, -50, 50);
let y = height / 2 + sin(angle) * 200 + map(noise(noiseOffsetY), 0, 1, -50, 50);
// Change radius and color cyclically
let dynamicRadius = radius + sin(angle * 2) * 20;
let r = map(sin(colorOffset), -1, 1, 100, 255);
let g = map(cos(colorOffset), -1, 1, 50, 200);
let b = map(sin(colorOffset + PI / 2), -1, 1, 150, 255);
// Draw the agent
fill(r, g, b, 200); // Dynamic color
ellipse(x, y, dynamicRadius, dynamicRadius);
// Update variables
angle += speed; // Increment cyclic motion
noiseOffsetX += 0.01; // Increment Perlin noise offsets
noiseOffsetY += 0.01;
colorOffset += 0.02; // Increment color change offset
}