大家可以看看這篇文章,寫得挺好的http://www.zhangxinxu.com/wordpress/2012/06/css3-transform-matrix-%E7%9F%A9%E9%98%B5/
2016-11-03
繪制任意邊的多邊形function drawStar(ctx,n,R,r ,x ,y,rot){ -Math.sin((deg/4+i*deg-rot)/180*Math.PI)*R+y);
ctx.lineTo(Math.cos(((deg-deg/4)+i*deg-rot)/180*Math.PI)*r+x,
-Math.sin(((deg-deg/4)+i*deg-rot)/180*Math.PI)*r+y);
}
ctx.lineTo(Math.cos(((deg-deg/4)+i*deg-rot)/180*Math.PI)*r+x,
-Math.sin(((deg-deg/4)+i*deg-rot)/180*Math.PI)*r+y);
}
2016-11-03
每個角72°
360/5=72°
每兩個外圈頂點跟圓心連在一起的角度為72
再用直角90-72=18
又因為72°平分兩個一模一樣的角度,所以除以2=36°
36°+18°=54°
360/5=72°
每兩個外圈頂點跟圓心連在一起的角度為72
再用直角90-72=18
又因為72°平分兩個一模一樣的角度,所以除以2=36°
36°+18°=54°
2016-11-02