<canvas id="canvas" width="200px" height="200px" ></canvas>
<script type="text/javascript">
var drawing = document.getElementById("canvas");
if(drawing.getContext){
var context=drawing.getContext("2d");
context.fillStyle="#ff0000";
context.fillRect(10,10,50,50);
context.globalCompositeOperation="destination-over";
context.fillStyle="rgba(0,0,255,1)";
context.fillRect(30,30,50,50);
}
<script type="text/javascript">
var drawing = document.getElementById("canvas");
if(drawing.getContext){
var context=drawing.getContext("2d");
context.fillStyle="#ff0000";
context.fillRect(10,10,50,50);
context.globalCompositeOperation="destination-over";
context.fillStyle="rgba(0,0,255,1)";
context.fillRect(30,30,50,50);
}