let n = 8
let img1, img2;
let C1, C2, Si, r1, r2, Se, c1, c2;
function preload() {
img1 = loadImage("/assets/twist.jpg");
img2 = loadImage("/assets/star.png");
}
function setup() {
createCanvas(600, 600);
angleMode(DEGREES)
background(200);
noStroke()
background(img1)
imageMode(CENTER)
}
function draw() {
translate(width/2,height/2)
t1 = 360*sin(frameCount/50)
push()
rotate(-t1/7)
image(img1,0,0,800,800)
pop()
twisting(t1)
twisting (t1+180)
}
function twisting(t){
for(let j = 0;j<n;j+=2){
for(let i = 0;i<100;i++){
x = 100*cos(t+i+j)-20*sin((t+i+j)*n)
y = 100*sin(t+i+j)+20*cos((t+i+j*n)*n)
s = 10+30*cos((t+i)*n)
image(img2,x-s/2,y-s/2,s,s)
}
}
fill(255)
for(let j = 0;j<n;j+=2){
for(let i = 0;i<100;i++){
x = 100*cos(t+i+j)+20*sin((t+i+j)*n)
y = 100*sin(t+i+j)-20*cos((t+i+j*n)*n)
s = 10+30*sin((t+i)*n)
image(img2,x-s/2,y-s/2,s,s)
}
}
}