Tell me please. How can I bring my entire array to the future field (drawn using canvas) and fill each cell with the colors corresponding to the number in the cell of the array. A field of canvas will look like a simple table.
Markup:
<canvas id="can1" width="300" height="300"></canvas>
Script:
function cubik() { var myCanvas = document.getElementById("can1"); if (!myCanvas.getContext) { return; } var myContext = myCanvas.getContext("2d"); //здесь будет нарисована таблица, еще не нашел решение! } cubik(); var myArr; function main(sizeX, sizeY) { myArr = Array(sizeX); for (var i = 0; i < myArr.length; i++) { myArr[i] = Array(sizeY); for (var j = 0; j < myArr[i].length; j++) { myArr[i][j] = Math.round(Math.random() * 4); } } } function () { main(20, 30); }