I want to write a program, that displays a rect, when the mouse clicks on the canvas element. I have certain modules, but somehow they seem not to be connected. I pasted the the code without a namespace in a JSFidlle:
displaying module
(function(){
display = (function(){
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
return {
canvas: canvas,
context : context
}
})();
})();
manager-module
(function(){
manager = (function(){
var canvas = display.canvas;
var context = display.context ;
var rect = function(){
ctx.fillRect(10,10,20,20);
}
return {
rect: rect
}
})();
})();
main-module
(function(){
canvas.addEventListener('mousedown', function(e) {
manager.rect;
}, 0);
})();