<html>
<head>
<script type="application/javascript">
function init() {
var canvas = document.getElementById("canvas");
if (canvas.getContext)
{
var ctx = canvas.getContext("2d");
ctx.fillStyle = "blue";
ctx.fillRect(25,25,100,50);
//Set the transparency value to 0.5
ctx.globalAlpha = 0.5;
ctx.globalCompositeOperation = "source-over";
ctx.fillStyle = "green";
ctx.fillRect(60,45,100,50);
}
}
</script>
<title> Compositing on canvas </title>
</head>
<body onload="init();">
<canvas id="canvas" width="900"
height="500"></canvas><br>
</body>
</html>
|