Finding a good book to master HTML5 can be very challenging: there are so many around - most with eye-catching titles and very complex substance.
Therefore,
Vivax Solutions strongly recommends
Core HTML5 Canvas for those who really want to delve into HTML5.
Please click the image to access
Amazon:
In this example, the background is an image made by using CSS in canvas element.
The balloon and its reflection are produced by two images.
The images are moved across the background by using JavaScript.
<script type="text/javascript">
var canvas = document.getElementById('Canvas_T');
var context = canvas.getContext('2d');
// image of the top balloon
var imgObj1 = new Image();
// image of the second balloon
var imgObj2 = new Image();
var i = 0; var j = 1; var x; var y;
// function for the movement
function circ() {
i = i + j;
if (i == 400) { j = -1; }
if (i == 0) { j = 1; }
context.clearRect(0, 0, 500, 400);
x = i;
y = Math.round(100 + 15 * Math.sin(i * Math.PI / 180));
context.drawImage(imgObj1, x, y);
imgObj1.src = '../images/hot.png';
context.drawImage(imgObj2, x, y + 180);
imgObj2.src = '../images/hot1.png';
}
</script>