anilashanbhag 0 Junior Poster in Training
<html>
<body>
<canvas id="example" width="800" height="600">
This text is displayed if your browser does not support HTML5 Canvas.
</canvas>
<script type="text/javascript">
var example = document.getElementById('example');
var context = example.getContext('2d');
for(var j=0;j<8;j++){
	for(var i=0;i<6;i++){
	context.fillStyle = "rgb(255,0,0)";
	context.fillRect(100*j, 100*i, 50, 50);
	}
}
</script>
</body>
</html>

how do i change the colour of each box - i mean i am not getting an idea of how to change it to the form rgb(255,10*i,0,0) ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.