Javascript examples for Canvas:Example
HTML Canvas fill
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <script type="text/javascript"> $(window).load(function(){//from ww w . ja v a2 s.c o m var c = document.getElementById("main"); var ctx = c.getContext("2d"); ctx.beginPath(); ctx.moveTo(200,300); ctx.lineTo(800,0); ctx.lineTo(1500,300); ctx.lineTo(200,300); ctx.closePath(); ctx.stroke(); ctx.fillStyle="#8ED6FF"; ctx.fill(); }); </script> </head> <body> <canvas id="main" height="1000" width="1500"></canvas> </body> </html>