
Originariamente inviata da
ndsoft
Avendo attentamente studiato l'utilizzo dell'oggetto canvas in w3schools.com, ho anche provato il seguente codice che dovrebbe disegnare sei cerchi uno sopra l'altro, colorati all'interno alternativamente di giallo e di rosso. Ma in realtà me li disegna tutti gialli. Secondo voi è un mio errore o è un bug?
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var y = 10;
for (i=0; i < 6; i++) {
if (c % 2 == 0) {
ctx.arc (20, y, 3, 0,2*Math.PI);
ctx.fillStyle="red";
ctx.fill();
} else {
ctx.arc (20, y, 3, 0,2*Math.PI);
ctx.fillStyle="yellow";
ctx.fill();
}
y += 10;
}
</script>
</body>
</html>
Utilizzo di Canvas:
http://www.w3schools.com/tags/tryit....l5_canvas_fill