50 lines
2.1 KiB
Plaintext
50 lines
2.1 KiB
Plaintext
//Config
|
|
int initialRadius = 5;
|
|
int radiusIncrease = 2;
|
|
int delay = 10; // Declare and initialize delay in frames
|
|
int bufferSize = 50; // Declare and initialize ring buffer size
|
|
|
|
int sourceX = mouseX; // Declare and initialize source point x coordinate to current mouse x coordinate
|
|
int sourceY = mouseY; // Declare and initialize source point y coordinate to current mouse y coordinate
|
|
int[] buffer = new int[bufferSize]; // Declare and initialize radius buffer
|
|
int[] sourceXBuffer = new int[bufferSize]; // Declare and initialize source point x coordinate buffer
|
|
int[] sourceYBuffer = new int[bufferSize]; // Declare and initialize source point y coordinate buffer
|
|
int[] colors = new int[bufferSize]; // Declare and initialize color buffer
|
|
int bufferIndex = 0; // Declare and initialize buffer index
|
|
int frameCount = 0; // Declare and initialize frame counter
|
|
|
|
|
|
void setup() {
|
|
size(800, 800); // Set canvas size
|
|
colorMode(HSB, 360, 100, 100); // Set color mode to HSB
|
|
}
|
|
|
|
void draw() {
|
|
background(255); // Clear canvas
|
|
|
|
for (int i = 0; i < bufferSize; i++) { // Iterate over ring buffer
|
|
int r = buffer[i]; // Get radius value from buffer
|
|
int x = sourceXBuffer[i]; // Get source point x coordinate from buffer
|
|
int y = sourceYBuffer[i]; // Get source point y coordinate from buffer
|
|
stroke(colors[i]); // Set stroke color from color buffer
|
|
noFill(); // Remove fill
|
|
ellipse(x, y, r, r); // Draw circle with radius and source point coordinates from buffers
|
|
|
|
buffer[i]+=radiusIncrease;
|
|
}
|
|
|
|
if (frameCount % delay == 0) { // Check if delay has passed
|
|
buffer[bufferIndex] = initialRadius; // Add current radius to buffer
|
|
sourceXBuffer[bufferIndex] = sourceX; // Add current source point x coordinate to buffer
|
|
sourceYBuffer[bufferIndex] = sourceY; // Add current source point y coordinate to buffer
|
|
colors[bufferIndex] = color(0); // Add random color to color buffer
|
|
bufferIndex = (bufferIndex + 1) % bufferSize; // Increment buffer index and wrap around if necessary
|
|
//radius = 5; // Reset radius to small value
|
|
}
|
|
|
|
sourceX = mouseX;
|
|
sourceY = mouseY;
|
|
//radius += 2; // Increment radius
|
|
frameCount++; // Increment frame counter
|
|
}
|