ctx代表整個(gè)畫布,那ctx.rotate(rot / 180 * Math.PI)是旋轉(zhuǎn)畫布而不是單個(gè)五角星嗎?
??????????? ctx.translate(xw, yw);
??????????? ctx.rotate(rot / 180 * Math.PI);
??????????? ctx.scale(R,R);
??????????? starPath(ctx);
五角星的繪制語(yǔ)句寫在了后面,那rotate 這個(gè)方法是在旋轉(zhuǎn)畫布?
通過相對(duì)位置讓小星星看起來是自己轉(zhuǎn)動(dòng)了嗎?
2016-08-26
rotate的旋轉(zhuǎn)是你當(dāng)前畫布里面的元素,繪制五角星,使用for循環(huán)畫出多個(gè)五角星,每次循環(huán)都使用了beginPath();
2017-10-26
45 * Math.PI/180,為什么是 180,而不是360?
2016-08-26
canvas的轉(zhuǎn)換不是針對(duì)整個(gè)canvas的,而是針對(duì)調(diào)用轉(zhuǎn)換方法之后繪制的shapes 或 paths。如下:
context.rotate(45 * Math.PI/180);
context.fillRect(50, 50, 50, 50);
? ?
順序很重要,反了就沒有旋轉(zhuǎn)的效果了。
此貼終結(jié)。
2016-08-26
我回過來想一想,canvas的旋轉(zhuǎn)是先把畫布轉(zhuǎn)好了,然后在旋轉(zhuǎn)過的畫布上畫星星,而不是把星星畫出來再動(dòng)態(tài)旋轉(zhuǎn)。