I have created 2 object. One creates a canvas object and append it to the body of the html and another one should draw a rectangle which isn't. What am I doing wrong?
window.onload = function(){
var oCanvas = {
canvas : document.createElement("canvas"),
ctx : document.createElement("canvas").getContext("2d"),
create : function(){
oCanvas.canvas.id = "canvas";
oCanvas.canvas.width = 350;
oCanvas.canvas.height = 350;
oCanvas.canvas.style.background = "yellow";
document.body.appendChild(oCanvas.canvas);
}
};
var oMap = {
createGrid : function(){
oCanvas.ctx.fillRect(50, 25, 150, 100);
}
};
oCanvas.create();
oMap.createGrid();
};