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);
line(width/2 - a, height/2, width/2 + a, height/2);
stroke(0, 0, 255);
line(width/2, height/2 - b, width/2, height/2 + b);
const x = width/2 + a * cos(-theta);
const y = height/2 + b * sin(-theta);
const xa = width/2 + b * cos(theta);
const yb = height/2 + b * sin(theta);
stroke(128);
strokeWeight(8);
point(xa, height/2);
point(width/2, yb);
strokeWeight(3);
line(width/2, yb, x, y);
stroke(0, 204, 0);
strokeWeight(8);
point(x, y);
points.push(createVector(x, y));
strokeWeight(3);
beginShape();
for (const p of points) {
vertex(p.x, p.y);
}
endShape();
theta += 1;
if (theta == 360) {
points.splice(0);
theta = 0;
}
}