1
When I put one squared in canvas the bottom turns white.
(function(){
var c = document.createElement("canvas");
var ctx = c.getContext('2d');
var fps = 30;
var height = 300;
var width = 300;
var Bloco = new bloco();
c.width = 300;
c.height = 300;
document.body.appendChild(c)
setInterval(draw(), 1000/fps)
function draw(){
background("black");
Bloco.put();
}
function bloco(x, y, size, color){
this.size = size;
this.x = x;
this.y = y;
this.color = color;
this.put = function(){
quadrado(10, 10, 10, "white");
}
}
function quadrado(x, y, size, color){
ctx.rect(x, y, size+x, size+y);
ctx.fillStyle = color;
ctx.fill();
}
function background(color){
ctx.rect(0, 0, width, height);
ctx.fillStyle = color;
ctx.fill();
}
})();
<body>
<script src="javascript.js" type="text/javascript"></script>
<body>
I wanted to know how to draw a squared without interfering in the color of bottom!