CanvasRenderingContext2D.lineWidth


           html5.jpg



설명


    CANVAS 에 선의 두께를 지정한다.


분류


    선 / 스타일


형태


    float CanvasRenderingContext2D.lineWidth


기본값


    1


예제


<html> 

<head> 

     <script type="application/javascript"> 

    function draw() { 

      var canvas = document.getElementById("canvas"); 

      if (canvas.getContext) { 

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

 

                  ctx.strokeStyle = "black"; 

           for (var i=1; i <= 10; i++) {  

                                ctx.lineWidth = i;

                                ctx.beginPath();

                                ctx.moveTo(10,5+i*15);

                                ctx.lineTo(140,5+i*15);

                                ctx.closePath();

                                ctx.stroke();

             }  

      } 

    } 

     </script> 

</head> 

<body onload="draw();"> 

     <canvas id="canvas" width="150" height="150"></canvas> 

</body> 

</html> 


결과


             lineWidth.png