S2
jS
Learn
Create Your Own
Split Screen
Go to Live Site
Next Page
For a rectangle with a frame, just combine the two techniques:
<HTML> <head> <title> My new Web Page </title> </head> <body> <canvas id=myCanvas width=300 height=300 style="background-color: pink;"> </canvas> <script> var ctx = myCanvas.getContext("2d"); ctx.fillStyle= "green"; ctx.strokeStyle= "red"; ctx.lineWidth= 4; ctx.fillRect(50, 50, 70, 90); ctx.strokeRect(50, 50, 70, 90); </script> </body> </html>