<canvas width="600" height="400"> </canvas>
<script>
function dibujarRectangulo(x,y,color,altura){
var pantalla = document.querySelector("canvas");
var pincel = pantalla.getContext("2d");
pincel.fillStyle = color;
pincel.fillRect(x,y,50,altura);
pincel.strokeStyle = "black";
pincel.strokeRect(x,y,50,altura);
}
dibujarRectangulo(50,50,"green",Math.round(Math.random()*510));
</script>