How to get an array of coordinates that make up a circle in canvas?

后端 未结 2 1576
半阙折子戏
半阙折子戏 2021-01-19 06:38

So, if this is the code I\'m using to draw a circle on my canvas:

ctx.beginPath();
ctx.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
ctx.lineWidth =          


        
2条回答
  •  忘掉有多难
    2021-01-19 07:06

    You are asking for the formula for a circle which is:

    radius*radius = (x-centerX)*(x-centerX) + (y-centerY)*(y-centerY)
    

    Or if you want to generate n points do something like this:

    for (i=0;i

提交回复
热议问题