xxxxxxxxxx
53
function setup() {
createCanvas(400, 400);
x = width / 2;
y = height / 2;
background(20);
angle = 0;
angleMode(DEGREES);
textSize(24);
col = color(random(255),random(255),random(255))
}
let x, y, angle;
let paused = false;
let col;
function draw() {
if (!paused) {
background(color(20,20,20));//,10));
fill(20);
noStroke();
rect(0, 0, width / 3, 30);
fill(220);
text("Angle: " + angle * -1, 0, 20);
stroke(220);
line(0, height / 2, width, height / 2);
line(width / 2, 0, width / 2, height);
push();
translate(width / 2, height / 2);
x = 100 * cos(angle);
y = 100 * sin(angle);
stroke(col);
line(x, y, 0, 0);
line(0, 0, width/2, 0);
circle(x, y, 20);
pop();
angle--;
if (angle < -360) {
angle = 0;
col = color(random(255),random(255),random(255))
}
}
}
function keyPressed() {
if (key == "p") paused = !paused;
if (key == "s") saveGif("circles.gif", 10);
}