let img1, img2;
let graph;
function preload() {
img1 = loadImage("/assets/gyration.jpg");
img2 = loadImage("/assets/star.png");
}
function setup() {
createCanvas(600, 600);
strokeWeight(0.25);
angleMode(DEGREES);
stroke(255);
imageMode(CENTER);
nVert = int(random(40, 100));
graph = [];
for (let i = 0; i < 600; i++) {
fill(255, 255, 255, 1);
graph[i] = {
x: randomGaussian(0, 10),
y: randomGaussian(0, 10),
size: random(i / 5, i / 2)
};
}
}
function draw() {
translate(width / 2, height / 2);
t1 = frameCount / 5;
rotate(t1 / 5);
image(img1, 0, 0, 900, 900);
noStroke();
push();
rotate(t1);
image(img2, 0, 0, 100, 100);
pop();
for (let i = 0; i < graph.length; i++) {
r = 200 + 5 * abs(graph[i].x);
g = 190 + 2 * abs(graph[i].x);
b = 180 + 3 * abs(graph[i].x);
fill(r, g, b, 2);
circle(
(i / 2) * cos(i + graph[i].x + t1) + 100 * sin(t1),
(i / 2) * sin(i + graph[i].y + t1) + 100 * cos(t1),
graph[i].size / 3
);
fill(r, g, b, 80);
circle(
(i / 2) * cos(i + graph[i].x + t1) + 100 * sin(t1),
(i / 2) * sin(i + graph[i].y + t1) + 100 * cos(t1),
1
);
push();
rotate(90);
fill(r, g, b, 2);
circle(
(i / 2) * cos(i + graph[i].x + t1) + 100 * sin(t1),
(i / 2) * sin(i + t1) + 100 * cos(t1),
graph[i].size / 3
);
fill(r, g, b, 80);
circle(
(i / 2) * cos(i + graph[i].x + t1) + 100 * sin(t1),
(i / 2) * sin(i + t1) + 100 * cos(t1),
1
);
pop();
rotate(120);
fill(r, g, b, 2);
circle(
(i / 2) * cos(i + graph[i].x + t1) + 100 * sin(t1),
(i / 2) * sin(i + graph[i].y + t1) + 100 * cos(t1),
graph[i].size / 3
);
fill(r, g, b, 80);
circle(
(i / 2) * cos(i + graph[i].x + t1) + 100 * sin(t1),
(i / 2) * sin(i + graph[i].y + t1) + 100 * cos(t1),
1
);
pop();
}
}
function keyPressed() {
setup();
draw();
}