ciao a tutti ho scritto uno script ma non riesco a capire dove sbaglio visto che nn mi disegno nulla
var element = [];
function Rettangolo(colore)
{
this.width = 50;
this.height = 50;
this.color = colore;
this.x = 20;
this.x = 100;
this.colora = function (c)
{
c.fillStyle = this.color;
ctx.fillRect(this.x,this.y,this.width,this.height) ;
ctx.fill();
var incremento = this.x + this.x + this.width;
this.x += incremento;
}
}
function load()
{
tela = document.getElementById('tela');
ctx = tela.getContext('2d');
element[0] = new Rettangolo('blue');
element[1] = new Rettangolo('red');
element[2] = new Rettangolo('violet');
for(i in element) {
element[i].colora(ctx);
}
}
window.onload = load;
non riesco a capire dove sbaglio grazie in anticipo a chi puo aiutarmi