How to draw and fill green square on canvas with fillStyle() and fillRect() in JavaScript

1 Answer

0 votes
<canvas id="canvas"></canvas>
<script type="text/JavaScript">   

var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");

ctx.fillStyle = "rgb(0, 220, 0)";  
ctx.fillRect(30, 30, 80, 80);
 
/*
run:  
    
   
*/
  
</script>

 

 



answered May 24, 2016 by avibootz
edited May 24, 2016 by avibootz
...