HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <canvas id="point" width="90" height="190">Your browser does not support the canvas element. </canvas> <script> var canvas = document.getElementById('point'); var ctx = canvas.getContext('2d'); // Moved square ctx.translate(0, 100); ctx.fillStyle = '#339933'; ctx.fillRect(0, 0, 80, 80); // Reset current transformation matrix to the identity matrix ctx.setTransform(1, 0, 0, 1, 0, 0); // Unmoved square ctx.fillStyle = '#8c8c8c'; ctx.fillRect(0, 0, 80, 80); </script> </body> </html>
OUTPUT
×

Save as Private