Code
Execute
<!DOCTYPE html> <html> <head> <title>wikitechy-translate()in canvas</title> </head> <body> <h1>wikitechy-translate()in canvas</h1> <canvas id="wikitechyCanvas" width="300" height="150" style="border:1px solid #d3d3d3;"> </canvas> <script> var canvas = document.getElementById("wikitechyCanvas"); var context = canvas.getContext("2d"); context.fillRect(20, 20, 120, 50); context.translate(70, 70); context.fillRect(0, 10, 120, 50); </script> </body> </html>
Result