I am attempting to populate a 3D array with dimensions of 16x16x16, all filled with the color "rgb(255, 48, 144)". My goal is then to draw a rectangle using this color by referencing its position in the array ( arr[15][3][9] ).
Here is my progress so far:
var ctx = document.getElementById("canvas").getContext("2d");
var canvas = document.getElementById("canvas");
var arr = new Array(16);
for(var i = 0; i < arr.length; i++){
arr[i] = new Array(16);
for(var j = 0; j < arr[i].length; j++){
arr[i][j] = "rgb(255, 48, 144)";
for(var k = 0; k < arr[i][j].length; k++){
arr[i][j][k] = "rgb(255, 48, 144)";
}
}
}
ctx.fillstyle = arr[15][3][9];
ctx.fillRect(0, 0, 100, 100);
<!doctype HTML>
<html>
<head>
<meta charset="UTF-8">
<title> Fargekube </title>
</head>
<body>
<canvas id="canvas" width="200" height="200></canvas>
</body>
</html>