-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcanvas.js
45 lines (37 loc) · 1.03 KB
/
canvas.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
var canvas;
var ctx;
var img;
function prepareCanvas() {
ctx.font = "30px Arial";
ctx.fillText("Hello World",10,50);
for(var i=0; i<9; i++)
for(var j=0; j<9; j++)
setTimeout( drawToCanvas, counter++*time, ctx, j, i, testBoard[i][j], "black");
counter=1;
}
function drawToCanvas(i, j, num, color) {
ctx.font = "30px Arial";
ctx.fillStyle="black";
//ctx.fillText("Slow Motion",100,640);
ctx.fillStyle = 'white';
ctx.fillRect(i*63+22, j*64+19, 52, 52);
ctx.fillStyle = color;
ctx.font = "bold 30pt Courier";
if(num==0) return;
ctx.fillText(num, i*63+35, j*63+62);
//drawCanvas(ctx);
}
function initCanvas() {
canvas = document.getElementById('mycanvas');
ctx = canvas.getContext('2d');
ctx.clearRect(0,0,600,600);
img = new Image();
img.src = "./sudoku-leer.svg";
ctx.drawImage(img, 10, 10, 580, 580);
ctx.lineWidth=5;
ctx.strokeRect(10, 10, 580, 580);
for(var i=0; i<9; i++)
for(var j=0; j<9; j++)
if(testBoard[i][j]!=0)
drawToCanvas(j, i, testBoard[i][j], "black");
}