xxxxxxxxxx
83
function preload() {
bg = loadImage("https://cdn.glitch.com/cb24feb5-aaf2-4e7f-97d0-36fe06210c69%2Fastrologia-II-600px.png?v=1601982052547");
}
// clock parameters
//source reference:https://p5js.org/examples/input-clock.html
let cx, cy;
let secondsRadius;
let minutesRadius;
let hoursRadius;
let clockDiameter;
//mouse
let offsetX = 10;
function setup() {
createCanvas(600, 600);
stroke(255);
angleMode(radians);
//clock
let radius = min(width, height) / 2;
secondsRadius = radius * 0.67;
minutesRadius = radius * 0.5;
hoursRadius = radius * 0.42;
clockDiameter = radius * 1.6;
cx = width / 2;
cy = height / 2;
//secret text
textAlign(CENTER);
textSize(28);
}
function draw() {
background(bg);
// Draw the clock background
noStroke();
fill(255, 215, 0); // gold
ellipse(cx, cy, clockDiameter + 25, clockDiameter + 25);
fill(64, 64, 64); // grey
ellipse(cx, cy, clockDiameter, clockDiameter);
// Angles for sin() and cos() start at 3h;
// subtract HALF_PI to make them start at the top
let s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI;
let m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI;
let h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI;
// hands of clock
stroke(255, 215, 0);
strokeWeight(2);
line(cx, cy, cx + cos(s) * secondsRadius, cy + sin(s) * secondsRadius);
strokeWeight(3);
line(cx, cy, cx + cos(m) * minutesRadius, cy + sin(m) * minutesRadius);
strokeWeight(4);
line(cx, cy, cx + cos(h) * hoursRadius, cy + sin(h) * hoursRadius);
//loop
translate(width / 2, height / 2);
for (var i = 0; i < 12; i++) {
rotate(PI / 6);
ellipse(140, 140, 20, 20);
noFill();
}
// secret text
textAlign(CENTER);
text('La Resistenza!');
if (mouseIsPressed) {
blendMode(DIFFERENCE);
fill(255, 255, 255);
} else {
blendMode(BLEND);
}
}