• canvas元素绘制太极图


    <!DOCTYPE html>
    <html>
    <head>
    <title>canvas example</title>
    <meta charset="utf-8">
    </head>
    <body>
    <canvas id="canvas" width="600px" height="600px"></canvas>

    <script>
    var canvas=document.getElementById("canvas");
    var context=canvas.getContext('2d');
    context.beginPath();
    context.arc(300,300,200,0,2*Math.PI,false);
    context.stroke();
    context.beginPath();
    context.fillStyle="black";
    context.arc(300,300,200,Math.PI/2,Math.PI*3/2,false);
    context.fill();
    context.beginPath();
    context.fillStyle="white";
    context.arc(300,200,100,0,Math.PI*2,false);
    context.fill();
    context.beginPath();
    context.fillStyle="black";
    context.arc(300,400,100,0,Math.PI*2,false);
    context.fill();
    context.beginPath();
    context.fillStyle="black";
    context.arc(300,200,30,0,Math.PI*2,false);
    context.fill();
    context.beginPath();
    context.fillStyle="white";
    context.arc(300,400,30,0,Math.PI*2,false);
    context.fill();
    </script>
    </body>
    </html>


    效果图如下:




  • 相关阅读:
    Add Binary
    Java笔记之String
    Java笔记之数组
    Merge Two Sorted Lists
    Remove Nth Node From End of List
    Longest Common Prefix
    Roman to Integer
    Palindrome Number
    Reverse Integer
    _cdel stdcall
  • 原文地址:https://www.cnblogs.com/MrZWJ/p/10036316.html
Copyright © 2020-2023  润新知