<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Extension methods</title></Head><Body> <CanvasID= "Canvas"style= "margin:0 auto;border:1px #ddd Solid">the current browser does don't support Canvas, can replace the browser a try! </Canvas> <Script> varCanvas=document.getElementById ('Canvas'); //the new APICanvasRenderingContext2D.prototype.fillStar= function(R,r,x,y,rot) { This. Beginpath (); for(varI=0; I<5; I++){ This. LineTo (Math.Cos ( -+I* the -rot)/180*math.pi) *r+x, -Math.sin (( -+I* the -rot)/180*math.pi) *r+y); This. LineTo (Math.Cos ( Wu+I* the -rot)/180*math.pi) *r+x, -Math.sin (( Wu+I* the -rot)/180*math.pi) *r+y); } This. Closepath (); This. Fill (); } window.onload= function() {canvas.width= 1024x768; Canvas.height= 768; if(Canvas.getcontext ('2d')){ varContext=Canvas.getcontext ('2d'); //beginContext.fillstyle= "#058"; //Call the new APIContext.fillstar ( Max, -, -, -,0) }Else{alert ('the current browser does not support canvas, please change the viewer and try again! '); } } </Script></Body></HTML>
Canvas-a13prototype.html