Code
Execute
<!DOCTYPE html> <html> <head> <title>wikitechy-setTransform() Method in canvas</title> </head> <body> <h1>wikitechy-setTransform() Method in canvas<h1> <canvas id="wikitechyCanvas" width="400" height="250" style="border:1px solid #d3d3d3;"> </canvas> <script> var canvas = document.getElementById("wikitechyCanvas"); var context = canvas.getContext("2d"); context.fillStyle = "skyblue"; context.fillRect(10, 10, 250, 100); context.setTransform(4,0.5, -0.5, 1, 30, 15); context.fillStyle = "pink"; context.fillRect(0, 0, 250, 100); context.setTransform(1,0.5, -0.5, 1, 30, 10); context.fillStyle = "blue"; context.fillRect(0, 0, 250, 100); </script> </body> </html>
Result