xxxxxxxxxx
51
const a = 150;
const b = 75;
let theta = 0;
const points = [];
function setup() {
createCanvas(480, 480);
angleMode(DEGREES);
}
function draw() {
background(255);
strokeWeight(3);
noFill();
stroke(255, 0, 0);
circle(width/2, height/2, a*2);
stroke(0, 0, 255);
circle(width/2, height/2, b*2);
const x1 = width/2 + a * cos(theta);
const y1 = height/2 + a * sin(theta);
const x2 = width/2 + b * cos(theta);
const y2 = height/2 + b * sin(theta);
stroke(128);
strokeWeight(8);
point(x1, y1);
point(x2, y2);
strokeWeight(3);
line(x1, 0, x1, height);
line(0, y2, width, y2);
stroke(0, 204, 0);
strokeWeight(8);
point(x1, y2);
points.push(createVector(x1, y2));
strokeWeight(3);
beginShape();
for (const p of points) {
vertex(p.x, p.y);
}
endShape();
theta += 1;
if (theta == 360) {
points.splice(0);
theta = 0;
}
}