大家可以看看這篇文章,寫(xiě)得挺好的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
每個(gè)角72°
360/5=72°
每?jī)蓚€(gè)外圈頂點(diǎn)跟圓心連在一起的角度為72
再用直角90-72=18
又因?yàn)?2°平分兩個(gè)一模一樣的角度,所以除以2=36°
36°+18°=54°
360/5=72°
每?jī)蓚€(gè)外圈頂點(diǎn)跟圓心連在一起的角度為72
再用直角90-72=18
又因?yàn)?2°平分兩個(gè)一模一樣的角度,所以除以2=36°
36°+18°=54°
2016-11-02
不太明白canvas的坐標(biāo)系都是想對(duì)什么的坐標(biāo)系,是相對(duì)于自己的還是相對(duì)于瀏覽器或者web的,如何獲取鼠標(biāo)在畫(huà)布上的位置
2016-10-30
var x=Math.abs(Math.random()*canvas.width-2r)+r;
var y=Math.abs(Math.random()*canvas.height-2r)+r;
這么設(shè)置即可都在畫(huà)布內(nèi),看懂的不用贊。
var y=Math.abs(Math.random()*canvas.height-2r)+r;
這么設(shè)置即可都在畫(huà)布內(nèi),看懂的不用贊。
2016-10-29