HTML5 canvas transform() ·½·¨
ʵÀý
»æÖÆÒ»¸ö¾ØÐΣ»Í¨¹ý transform() Ìí¼ÓÒ»¸öеı任¾ØÕó£¬ÔٴλæÖƾØÐΣ»Ìí¼ÓÒ»¸öеı任¾ØÕó£¬È»ºóÔٴλæÖƾØÐΡ£Çë×¢Ò⣬ÿµ±Äúµ÷Óà transform() ʱ£¬Ëü¶¼»áÔÚǰһ¸ö±ä»»¾ØÕóÉϹ¹½¨£º
JavaScript:
var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.fillStyle="yellow"; ctx.fillRect(0,0,250,100)ctx.transform(1,0.5,-0.5,1,30,10);
ctx.fillStyle="red"; ctx.fillRect(0,0,250,100);ctx.transform(1,0.5,-0.5,1,30,10);
ctx.fillStyle="blue"; ctx.fillRect(0,0,250,100);
ä¯ÀÀÆ÷Ö§³Ö
Internet Explorer 9¡¢Firefox¡¢Opera¡¢Chrome ÒÔ¼° Safari Ö§³Ö transform() ·½·¨¡£
×¢ÊÍ£ºInternet Explorer 8 »ò¸üÔçµÄä¯ÀÀÆ÷²»Ö§³Ö <canvas> ÔªËØ¡£
¶¨ÒåºÍÓ÷¨
»²¼ÉϵÄÿ¸ö¶ÔÏó¶¼ÓµÓÐÒ»¸öµ±Ç°µÄ±ä»»¾ØÕó¡£
transform() ·½·¨Ìæ»»µ±Ç°µÄ±ä»»¾ØÕó¡£ËüÒÔÏÂÃæÃèÊöµÄ¾ØÕóÀ´²Ù×÷µ±Ç°µÄ±ä»»¾ØÕó£º
a c e b d f 0 0 1
»»¾ä»°Ëµ£¬transform() ÔÊÐíÄúËõ·Å¡¢Ðýת¡¢Òƶ¯²¢Çãбµ±Ç°µÄ»·¾³¡£
×¢ÊÍ£º¸Ã±ä»»Ö»»áÓ°Ïì transform() ·½·¨µ÷ÓÃÖ®ºóµÄ»æÍ¼¡£
×¢ÊÍ£ºtransform() ·½·¨µÄÐÐΪÏà¶ÔÓÚÓÉ rotate(), scale(), translate(), or transform() Íê³ÉµÄÆäËû±ä»»¡£ÀýÈ磺Èç¹ûÄúÒѾ½«»æÍ¼ÉèÖÃΪ·Åµ½Á½±¶£¬Ôò transform() ·½·¨»á°Ñ»æÍ¼·Å´óÁ½±¶£¬ÄúµÄ»æÍ¼×îÖÕ½«·Å´óËı¶¡£
Ìáʾ£ºÇë²é¿´ setTransform() ·½·¨£¬Ëü²»»áÏà¶ÔÓÚÆäËû±ä»»À´·¢ÉúÐÐΪ¡£
JavaScript Óï·¨£º
context.transform(a,b,c,d,e,f);
²ÎÊýÖµ
²ÎÊý | ÃèÊö |
---|---|
a | ˮƽËõ·Å»æÍ¼ |
b | ˮƽÇãб»æÍ¼ |
c | ´¹Ö±Çãб»æÍ¼ |
d | ´¹Ö±Ëõ·Å»æÍ¼ |
e | Ë®Æ½ÒÆ¶¯»æÍ¼ |
f | ´¹Ö±Òƶ¯»æÍ¼ |