xxxxxxxxxx
let g;
let hu;
function setup() {
createCanvas(1112, 834);
colorMode(HSB, 360, 100, 100, 100);
angleMode(DEGREES);
noSmooth();
hu = random(360);
g = createGraphics(width * sqrt(2), width * sqrt(2));
g.colorMode(HSB, 360, 100, 100, 100);
g.angleMode(DEGREES);
g.background(0, 0, 98);
drawGraphic(g);
}
function draw() {
background(0, 0, 100);
let rMax = width * sqrt(2);
for (let r = rMax; r > 0; r -= 30) {
push();
translate(width / 2, height / 2);
rotate(-frameCount+map(r, rMax, 0, 0,90) * tan((frameCount/5+90-(r / rMax) * 90))%90);
noStroke();
fill(r/3, 100, 100, 0);
circle(0, 0, r);
drawingContext.clip();
imageMode(CENTER);
image(g, 0, 0);
imageMode(CORNER);
pop();
hu++;
}
// noLoop();
}
function drawGraphic(target) {
target.push();
target.translate(target.width / 2, target.height / 2);
target.noStroke();
target.fill(hu, 100, 100);
let r = sqrt(sq(target.width) + sq(target.height));
let angleStep = 15;
let rMin = 0;
for (let angle = 0; angle < 360; angle += angleStep) {
target.fill(angle, 100, 100);
target.triangle(
cos(angle) * rMin,
sin(angle) * rMin,
cos(angle - angleStep / 4) * r,
sin(angle - angleStep / 4) * r,
cos(angle + angleStep / 4) * r,
sin(angle + angleStep / 4) * r
);
}
target.pop();
}
// save jpg
let lapse = 0; // mouse timer
function mousePressed(){
if (millis() - lapse > 400){
save("img_" + month() + '-' + day() + '_' + hour() + '-' + minute() + '-' + second() + ".jpg");
lapse = millis();
}
}