canvas 로 원그리기



html)

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>
    <meta charset="utf-8">
    <meta name="viewport" 
          content="width=device-width, height=device-height, 
                     minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0">
    <title>Insert title here</title>
    <script type="text/javascript">
    window.onload = function(){
        var canvas = document.getElementById("canvas");
        if(canvas.getContext){
            var draw = canvas.getContext("2d");
            
            //원
            draw.beginPath();
            //arc(중심점x, 중심점y, 반지름, 시작각도, 끝각도, 방향)
            //true : 반시계 방향 , false : 시계 방향
            draw.arc(100100500, Math.PI*2true);
            draw.lineWidth = 10;
            draw.strokeStyle = "#00f";
            draw.stroke();
        }
    }
    </script>
</head>
 
<body>
    <canvas id="canvas" width="300px" height="300px"></canvas>
</body>
</html>
cs



결과

+ Recent posts