[英]What are the benefits of using a setTransform for when drawing on a Canvas?
我仍然不確定甚至不確定setTransform的功能。 我在互聯網上找到了此代碼示例,並一直在弄亂它,以查看對setTransform所做的不同更改。 使用setTransform變量的真正用途和好處是什么,而不是僅繪制一個新的矩形。
問題:使用setTransform有什么好處和用途?
碼:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillStyle="yellow";
ctx.fillRect(0,0,125,50)
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);
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.