xxxxxxxxxx
95
let s;
let sX, sY;
let rX = 100,
rY = 100,
rSize = 180;
let t = 0;
let h1, h2, h3;
let v1, v2, v3;
let str1, str2, str3, str4;
let str1a, str2a, str3a, str4a;
let hArray = [];
let vArray = [];
let str1Array = [];
let str1aArray = [];
function setup() {
createCanvas(windowWidth, windowHeight);
sX = width / 4;
sY = height / 4;
h1 = sY;
h2 = sY * 2;
h3 = sY * 3;
v1 = sX;
v2 = sX * 2;
v3 = sX * 3;
s = createGraphics(sX, sX);
frameRate(25)
s.rY = 100;
}
function draw() {
background(0);
t++;
//Animation
s.rX = 100
// BASE IMAGE
s.background(0);
s.fill(0, 0, 255);
s.rectMode(CENTER);
s.translate(s.rX, s.rY);
s.rotate((t * Math.PI) / 80);
s.ellipse(0, 0, rSize, rSize/2);
s.resetMatrix();
//Variables & Arrays
v1 = map(mouseX, 0, width, width/4 * 0.2, width/2, true);
v2 = map(mouseX, 0, width, width/4, width/2 * 1.6, true);
v3 = map(mouseX, 0, width, width/4 * 3 * 0.8, width/2 * 1.9, true);
h1 = map(mouseY, 0, height, height / 4 * 0.2, height / 2, true);
h2 = map(mouseY, 0, height, height / 4, height / 2 * 1.6, true);
h3 = map(mouseY, 0, height, height / 4 * 3 * 0.8, height / 2 * 1.9, true);
strW1 = map(mouseX, 0, width, 0.2, 2, true);
strW2 = map(mouseX, 0, width, 0.8, 1.4, true);
strW3 = map(mouseX, 0, width, 1.4, 0.8, true);
strW4 = map(mouseX, 0, width, 2, 0.2, true);
strH1 = map(mouseY, 0, height, 0.2, 2, true);
strH2 = map(mouseY, 0, height, 0.8, 1.4, true);
strH3 = map(mouseY, 0, height, 1.4, 0.8, true);
strH4 = map(mouseY, 0, height, 2, 0.2, true);
hArray = [0, h1, h2, h3];
vArray = [0, v1, v2, v3];
strWArray = [strW1, strW2, strW3, strW4];
strHArray = [strH1, strH2, strH3, strH4];
//Drawing
for (x = 0; x < hArray.length; x++) {
for (y = 0; y < vArray.length; y++) {
s.rY += Math.cos(t -x*3) *10;
translate(vArray[y], hArray[x]);
scale(strWArray[y], strHArray[x]);
image(s, 0, 0);
resetMatrix();
}
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}