xxxxxxxxxx
float angle = 0.0;
float scalar = 2;
float speed = 0.05;
int numSpirals = 200;
int gridNum = 10;
// offset
float [] offsetX = new float [numSpirals];
float [] offsetY = new float [numSpirals];
//x and y for spirals
float x;
float y;
void setup() {
size(500, 500);
stroke(242, 47, 12, 30);
fill(242, 47, 12, 30);
background(255);
smooth();
// // spread out radomly across screen
// for (int i = 0; i < numSpirals; i++){
// offsetX [i] = random (width);
// offsetY [i] = random (height);
// }
// grid using modulo
for (int i = 0; i < numSpirals; i++){
// this is how video pixels are manupulated. as video stores pixel info as an array, not a pixel grid
// for x = i % 5 draws up to 5 rows of thing; y = i / 5 makes it all the same, while all the xs are the same
// anything divided by that thing moves slower than the whole or modulo, so this way our y increases at a slower rate than our x
offsetX [i] = (i % gridNum)*50 + 20;
offsetY [i] = floor(i / gridNum)* 50 + 20;
}
// // grid using stacked for loop
//int i = 0; // counter
//for (int y = 20; y < height-10; y = y+ 50) {
// for (int x = 20; x < width-10; x = x + 50) {
// offsetX[i] = x;
// offsetY[i] = y;
// i++;
// i%=numSpirals; // using modulo to reset the array so it doesn't cross numSpirals
// }
//}
}
void draw() {
// draws the spirals
for (int i = 0; i < numSpirals; i++) {
x = offsetX [i] + cos(angle) * scalar;
y = offsetY [i] + sin(angle) * scalar;
ellipse(x, y, 2, 2);
}
// put this outside the for loop to reduce speed
angle += speed;
scalar += speed;
}