<Scripttype= "Text/javascript"src= "Jquery-2.2.0.min.js"></Script><CanvasID= "Canvas"width= " the"Height= "1134"></Canvas><Script> //Paint the Stars functionDraw (id) {varCanvas=document.getElementById (ID); varContext=Canvas.getcontext ('2d'); Context.fillstyle= "#000"; //Context.strokestyle = "#f60"; //context.linewidth = 5;Context.fillrect (0, 0, -, 1134); //Context.fillstyle = "#fff"; //context.filltext ("Filltext", 0, 0); //********************************** starsContext.font= "Bold 14px Arial"; Context.textalign= " Left"; Context.textbaseline= "Top"; //Context.strokestyle = "Red";Context.fillstyle= "#fff"; //Context.filltext ("*", 0, 0); //For (var i = 0; i < i++) { //g.drawstring ("*", (int) (Math.random () * 1024x768), //(int) (Math.random () * 768)); //} for (varI= 0; I< -; I++) {Context.filltext ("*", Math.random ()* -, Math.random ()* 1134); } //********************************* Moon //G.filloval ( +----); //G.setcolor (color.black); //G.filloval (780, n, +);Context.beginpath (); Context.arc ( -, -, -, 0, 2 *Math.PI,true); Context.closepath (); Context.fillstyle= '#f6ee74'; Context.fill (); Context.beginpath (); Context.arc (380, the, -, 0, 2 *Math.PI,true); Context.closepath (); Context.fillstyle= "#000"; Context.fill (); //********************************* Loading Pictures varBeauty= NewImage (); BEAUTY.SRC= "1.png"; Beauty.onload= function () //Make sure the picture is loaded{context.drawimage (Beauty, -, -, -, -); } } $(function() {Draw ("Canvas"); varCanvas=document.getElementById ("Canvas"); Canvas.onclick= function () { varContext=Canvas.getcontext ('2d'); Context.font= "Bold 14px Arial"; Context.textalign= " Left"; Context.textbaseline= "Top"; Context.fillstyle= "#fff"; for (varI= 0; I< -; I++) {Context.filltext ("*", Math.random ()* -, Math.random ()* 1134); } }; });</Script>
Canvas Starry Sky