xxxxxxxxxx
23
let x; let y; let angle; let r = 100; let d = 30;
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
}
function draw() {
background(220);
angle = map(mouseX, 0, width, 0, 360);
print(angle);
angle2 = 90-angle;
// angle = 45;
translate(width/2, height/2);
x = r*cos(angle);
y = r*sin(angle);
line(0, 0, x, y);
// ellipse(x, y, 10, 10);
x2 = d*sin(angle);
y2 = d*cos(angle);
line(x - x2, y + y2, x + x2, y - y2);
}