<!doctype html> <html> <head> <link rel="stylesheet" type="text/css" media="all" href="css/reset.css" /> <!-- reset css --> <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script> <style> body{ background-color: ivory; } canvas{border:1px solid red;} </style> <script> var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); function star(ctx, x, y, r, p, m) { ctx.save(); ctx.beginPath(); ctx.translate(x, y); ctx.moveTo(0, 0 - r); for (var i = 0; i < p; i++) { ctx.rotate(Math.PI / p); ctx.lineTo(0, 0 - (r * m)); ctx.rotate(Math.PI / p); ctx.lineTo(0, 0 - r); } ctx.fill(); ctx.restore(); } star(ctx, 100, 100, 90, 5, 0.5); </script> </head> <body> <canvas id="canvas" width=300 height=300></canvas> </body> </html>
star
document ready event
script
body
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)