Prev Demo
Scaling
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>canvas scaling</title> </head> <body> <canvas id="myCanvas" width="500" height="200"></canvas> <script> var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); var rectWidth = 14; var rectHeight = 12; context.scale(12, 16); context.fillStyle = 'orange'; context.fillRect(7, 6, 14, 12); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output