• H5 canvas 直线和三角形


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>canvas</title>
    </head>
    <body>
        <canvas id="canvas" width="500px" height="500px;" style="border: 1px solid #000;"></canvas>
    
    <script>
        window.onload = function(){
            var canvas = document.getElementById('canvas');
            canvas.width = 1024;
            canvas.height = 768;
            var cxt = canvas.getContext("2d");
            cxt.moveTo(100,100);
            cxt.lineTo(300,300);
            cxt.lineTo(100,300);
            cxt.lineTo(100,100);
    
            cxt.fillStyle = "rgb(2,100,30)";
            cxt.fill();
    
            cxt.lineWidth = 1;
            cxt.strokeStyle = "red";
            cxt.stroke();
            cxt.closePath();
            cxt.moveTo(100,400)
            cxt.lineTo(400,400)
            cxt.lineTo(300,400)
            cxt.strokeStyle = "green";
            cxt.stroke();
        }
    </script>
    </body>
    </html>
    View Code
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>canvas</title>
    </head>
    <body>
        <canvas id="canvas" width="500px" height="500px;" style="border: 1px solid #000;"></canvas>
    
    <script>
        window.onload = function(){
            var canvas = document.getElementById('canvas');
            canvas.width = 1024;
            canvas.height = 768;
            var cxt = canvas.getContext("2d");
            cxt.moveTo(100,100);
            cxt.lineTo(300,300);
            cxt.lineTo(100,300);
            cxt.lineTo(100,100);
    
            cxt.fillStyle = "rgb(2,100,30)";
            cxt.fill();
    
            cxt.lineWidth = 1;
            cxt.strokeStyle = "red";
            cxt.stroke();
            cxt.closePath();
            cxt.moveTo(100,400)
            cxt.lineTo(400,400)
            cxt.lineTo(300,400)
            cxt.strokeStyle = "green";
            cxt.stroke();
        }
    </script>
    </body>
    </html>

  • 相关阅读:
    python实训day8
    python实训day7
    python实训day6
    python实训day5
    python实训day4
    python实训day3
    python实训day2
    python实训day1
    MyBatis入门-insert标签介绍及使用
    Shell入门-Shell脚本开发规范
  • 原文地址:https://www.cnblogs.com/arealy/p/7736992.html
Copyright © 2020-2023  润新知