let img1, img2;
let graph
function preload() {
img1 = loadImage("/assets/weight.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<nVert;i++){
graph[i] = {
x1: random(-width/3,width/3),
y1: random(-width/3,width/3),
x: 10,
y:10,
weight: int(random(1,10)),
c1: floor(random(0,nVert-0.001)),
c1W: int(random(1,5)),
c2: floor(random(0,nVert-0.001)),
c2W: int(random(1,5))
}
}
}
function draw() {
translate(width / 2, height / 2);
t1 = frameCount ;
rotate(t1/15)
image(img1,0,0,850,850)
noFill()
strokeWeight(0.8)
n = -1
for(let i = 0;i<nVert;i++){
fill(255)
stroke(150+50*graph[i].c1W,150+45*graph[i].weight,150+45*graph[i].c2W,70)
graph[i].x = graph[i].x1+50*cos(t1*graph[i].weight/10*pow(-1,graph[i].weight));
graph[i].y = graph[i].y1+50*sin(t1*graph[i].weight/10*pow(-1,graph[i].weight));
image(img2,graph[i].x,graph[i].y,20,20)
for(let j = 0;j<graph[i].weight;j++){
noFill()
circle(graph[i].x,graph[i].y,30- j*3)
}
for(let j = 0;j<graph[i].c1W;j++){
n=n*-1
line(graph[i].x+j*2*n,graph[i].y+j*2*n,graph[graph[i].c1W].x+j*2*n,graph[graph[i].c1W].y+j*2*n)
}
}
}
function keyPressed(){
setup()
draw()
}