function drawPolygonPath(sideNum, radius, originX, originY, ctx){
ctx.beginPath();
const unitAngle = Math.PI * 2 / sideNum; //计算单元角度
let angle = 0; //初始角度
let xLength, yLength;
// ctx.moveTo(originX, originY);
for(let i = 0; i < sideNum; i++){ //遍历计算点,并lineTo()绘制路径
xLength = radius * Math.cos(angle);
yLength = radius * Math.sin(angle);
ctx.lineTo(originX + xLength, originY - yLength);//绘制路径
angle += unitAngle;
}
ctx.closePath();//闭合路径,也可在for循环中多一次循环lineTo()至起点
}