Source Code:
(back to article)
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> <style type="text/css"> canvas { border: 1px solid black; } </style> </head> <body onload="paint()"> <script type="text/javascript"> function paint() { let canvas = document.getElementById('tutorial'); let ctx = canvas.getContext('2d'); ctx.fillStyle = "green"; ctx.fillRect(10, 10, 100, 100); } </script> <canvas id="tutorial" width="250" height="250"></canvas> </body> </html>
Result:
Report an issue