Carregando uma imagem em uma tela com javaScript

Oi tudo im atualmente testando usando o elemento de tela para desenhar todos os fundos (vou adicionar efeitos mais tarde para essas imagens mais tarde e é a razão im não usando css para carregar as imagens), que disse que estou tendo dificuldade em carregar uma imagem para a tela. aqui está o código:

<html>

<head>

    <title>Canvas image testing</title>

    <script type="text/javascript">
        function Test1() {
            var ctx = document.getElementById('canvas');
            if (canvas.getContext) {

                var ctx = canvas.getContext('2d');

                //Loading of the home test image - img1
                var img1 = new Image();
                img1.src = 'img/Home.jpg';

                //drawing of the test image - img1
                img1.onload = function () {
                    //draw background image
                    ctx.drawimage(img1, 0, 0);
                    //draw a box over the top
                    ctx.fillStyle = "rgba(200, 0, 0, 0.5)";
                    ctx.fillRect(0, 0, 500, 500);

                };
            }

        }


    </script>

    <style type="text/css">
        canvas { border: 2px solid black; width: 100%; height: 98%; }
    </style>
</head>

<body onload="Test1();">

    <canvas id="canvas" width="1280" height="720"></canvas>


</body>

Eu acho que não estou carregando a imagem corretamente, mas não tenho certeza.

questionAnswers(4)

yourAnswerToTheQuestion