试图通过圆画一条线
这是我的代码: https://codepen.io/ethan-horrigan/pen/OrRLXx
var r = 200;
var x1 = 800 / 2;
var y1 = 540 / 2;
var x = r * Math.cos(Math.PI / 180 * 135) + x1;
var y = r * Math.sin(Math.PI / 180 * 315) + y1;
ctx.beginPath();
ctx.arc(x1, y1, r, 0, Math.PI * 2, false);
ctx.moveTo(x1,y1);
ctx.lineTo(x, y);
ctx.stroke();
答案 0 :(得分:3)
答案 1 :(得分:0)
var r = 200;
var x1 = 800 / 2;
var y1 = 540 / 2;
var x = r * Math.cos(Math.PI * .75) + x1;
var y = r * Math.sin(Math.PI * 1.75) + y1;
ctx.beginPath();
ctx.arc(x1, y1, r, Math.PI * .25, Math.PI * 2.25, false);
ctx.lineTo(x, y);
ctx.stroke();