Home > front end >  HTML 5 canvas painting grid is what show only a vertical bar?
HTML 5 canvas painting grid is what show only a vertical bar?

Time:10-07

Code, plugins, may also be what reason



MyHtml. Html

<body>


Var aa=14;
Var chess=document. GetElementById (" mycanvas "); Var context=chess. GetContext (' 2 d ');
Var context2=chess. GetContext (' 2 d '); The context. StrokeStyle='yellow';
Var tree=[];
Var isling=[];
for(var i=0; i{
Tree [I]=[];
For (var j=0; J{tree [I] [j]=1;
}}
for(var i=0; i{isling [I]=[];
For (var j=0; J{isling [I] [j]=1; }}
The function drawChessBoard () {
for(var i=0; i{context. StrokeStyle='gray'; Context. MoveTo (15 + I * 30, 15); Context. The lineTo (15 + I * 30 * 30, 15 + aa);
The context. The stroke ();
Context. MoveTo (15, 15 + I * 30);//horizontal 15 lines, located 30 px;
Board of 14 * 14;
Context. The lineTo (aa, 15 + 15 + 30 * I * 30);
The context. The stroke (); }
} drawChessBoard ();//drawing board
Var mymap=new Array (36);
for(var i=0; i<36. I++)
{mymap [I]=1; }
</script>

CodePudding user response:

Code is no problem, just your line of single notes
//horizontal drawing 15 lines, located 30 px; Board of 14 * 14; 
this is a line, don't line breaks

  • Related