summaryrefslogtreecommitdiff
path: root/Base/res/html/misc/canvas-path-rect.html
blob: a132e52c0c6fd508a3e9ad41843bf35c598c0cbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html>
<head>
    <title>canvas path - rect example</title>
</head>
<body>
<canvas width=500 height=500></canvas>
<script>

    function drawRect() {
        var canvas = document.querySelector("canvas");
        var ctx = canvas.getContext("2d");
        ctx.fillStyle = 'black';
        ctx.fillRect(0, 0, 500, 500);

        ctx.fillStyle = 'red';
        ctx.beginPath();
        ctx.rect(10, 20, 150, 100);
        ctx.fill();

        ctx.fillStyle = 'green';
        ctx.beginPath();
        ctx.rect(200, 210, 100, 100);
        ctx.fill('evenodd');
    }

    drawRect();

</script>
</body>
</html>