HTML5 canvas setTransform() ·½·¨

ʵÀý

»æÖÆÒ»¸ö¾ØÐΣ¬Í¨¹ý setTransform() ÖØÖò¢´´½¨Ðµı任¾ØÕó£¬ÔٴλæÖƾØÐΣ¬ÖØÖò¢´´½¨Ðµı任¾ØÕó£¬È»ºóÔٴλæÖƾØÐΡ£Çë×¢Ò⣬ÿµ±Äúµ÷Óà setTransform() ʱ£¬Ëü¶¼»áÖØÖÃǰһ¸ö±ä»»¾ØÕóÈ»ºó¹¹½¨ÐµľØÕó£¬Òò´ËÔÚÏÂÃæµÄÀý×ÓÖУ¬²»»áÏÔʾºìÉ«¾ØÐΣ¬ÒòΪËüÔÚÀ¶É«¾ØÐÎÏÂÃæ£º

Your browser does not support the HTML5 canvas tag.

JavaScript:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");

ctx.fillStyle="yellow";
ctx.fillRect(0,0,250,100)

ctx.setTransform(1,0.5,-0.5,1,30,10);
ctx.fillStyle="red";
ctx.fillRect(0,0,250,100);

ctx.setTransform(1,0.5,-0.5,1,30,10);
ctx.fillStyle="blue";
ctx.fillRect(0,0,250,100);

Ç××ÔÊÔÒ»ÊÔ

ä¯ÀÀÆ÷Ö§³Ö

Internet Explorer 9¡¢Firefox¡¢Opera¡¢Chrome ÒÔ¼° Safari Ö§³Ö setTransform() ·½·¨¡£

×¢ÊÍ£ºInternet Explorer 8 »ò¸üÔçµÄä¯ÀÀÆ÷²»Ö§³Ö <canvas> ÔªËØ¡£

¶¨ÒåºÍÓ÷¨

»­²¼ÉϵÄÿ¸ö¶ÔÏó¶¼ÓµÓÐÒ»¸öµ±Ç°µÄ±ä»»¾ØÕó¡£

setTransform() ·½·¨°Ñµ±Ç°µÄ±ä»»¾ØÕóÖØÖÃΪµ¥Î»¾ØÕó£¬È»ºóÒÔÏàͬµÄ²ÎÊýÔËÐÐ transform()¡£

»»¾ä»°Ëµ£¬setTransform() ÔÊÐíÄúËõ·Å¡¢Ðýת¡¢Òƶ¯²¢Çãбµ±Ç°µÄ»·¾³¡£

×¢ÊÍ£º¸Ã±ä»»Ö»»áÓ°Ïì setTransform() ·½·¨µ÷ÓÃÖ®ºóµÄ»æÍ¼¡£

JavaScript Óï·¨£º

context.setTransform(a,b,c,d,e,f);

²ÎÊýÖµ

²ÎÊý ÃèÊö
a ˮƽÐýת»æÍ¼
b ˮƽÇãб»æÍ¼
c ´¹Ö±Çãб»æÍ¼
d ´¹Ö±Ëõ·Å»æÍ¼
e Ë®Æ½ÒÆ¶¯»æÍ¼
f ´¹Ö±Òƶ¯»æÍ¼
VUE