Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <canvas id="exampleCanvas" width="300" height="140" style="border:1px solid #dddddd;"> The HTML5 canvas tag is not supported by your browser. </canvas> <script> var c = document.getElementById("exampleCanvas"); var ctx = c.getContext("2d"); var grd = ctx.createLinearGradient(0, 0, 300, 0); grd.addColorStop(0, "#359900"); grd.addColorStop(1, "#ffffff"); ctx.fillStyle = grd; ctx.fillRect(20, 20, 250, 100); </script> </body> </html>