zoukankan      html  css  js  c++  java
  • 怎样设置线的宽度

    需要使用: ctx.lineWidth 属性; 它默认为1.0, 不能是负数.

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
    </head>
    
    <body>
        <canvas id="canv" width="300" height="300"></canvas>
        <script>
            function draw(){
                var canvas = document.getElementById("canv");
                if (!canvas.getContext) return;
                var ctx = canvas.getContext("2d");
    
                ctx.beginPath();
                ctx.moveTo(30, 150);
                ctx.lineTo(60, 150);
                ctx.lineWidth = 3;
                ctx.stroke();
    
                ctx.beginPath();
                ctx.moveTo(60, 150);
                ctx.lineTo(90, 150);
                ctx.lineWidth = 6;
                ctx.stroke();
    
                ctx.beginPath();
                ctx.moveTo(90, 150);
                ctx.lineTo(120, 150);
                ctx.lineWidth = 9;
                ctx.stroke();
    
                ctx.beginPath();
                ctx.moveTo(120, 150);
                ctx.lineTo(150, 150);
                ctx.lineWidth = 12;
                ctx.stroke();
            }
            draw();
        </script>
    </body>
    
    </html>

  • 相关阅读:
    BZOJ 3626: [LNOI2014]LCA(树链剖分+离线处理)
    python备用
    STL的使用。。备忘
    DP专题
    任务
    hdu 网络流题集
    hdu KM匹配题集
    hdu 差分约束题集
    hdu 2sat题集
    Codeforces Round #261 (Div. 2)
  • 原文地址:https://www.cnblogs.com/aisowe/p/11572893.html
Copyright © 2011-2022 走看看