WEB/html,CSS

[html] canvas 태그, 이미지나 애니메이션을 그리기[html] canvas 태그, 이미지나 애니메이션을 그리기

자바칩 프라푸치노 2021. 4. 7. 10:10

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 그래픽이나 애니메이션을 렌더링 -->
    <canvas id="canvas" width="200" height="150"></canvas>
    <script>
        const canvas = document.getElementById('canvas');
        const ctx = canvas.getContext('2d');
        ctx.fillStyle = 'rgb(200,0,0)';
        ctx.fillRect(10,10,50,50);
        ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
        ctx.fillRect (30305050);
    </script>
</body>
</html>
cs

 

728x90