麻烦老师检查,谢谢

来源:7-2 编程练习

qq_慕移动3101913

2020-03-02 17:43:16

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style>
        canvas{background-color:lightblue;}
    </style>
</head>
<body>
    <canvas id="canvas" width="800px" height="800px">
        您的浏览器不支持canvas
    </canvas>
    <script>
        var canvas=document.getElementById("canvas");
        var context=canvas.getContext("2d");
    
        //绘制圆形
        context.arc(400,400,200,0,Math.PI * 2, true);
        //进行区域剪辑
        context.clip();

        context.fillStyle = "#fff";
        context.fill();

        context.beginPath();    //清除之前的路径,重新开始新
        context.fillStyle = "#90EE90";
        context.fillRect(200,200,200,200);  //填充矩形

        context.beginPath();
        context.fillStyle = "RGB(128,0,128)";
        context.fillRect(400,200,200,200);

        context.beginPath();
        context.fillStyle = "RGB(255,165,0)";
        context.fillRect(200,400,200,200);

        context.beginPath();
        context.fillStyle = "RGB(255,192,203)";
        context.fillRect(400,400,200,200);

    </script>
</body>
</html>


写回答

1回答

好帮手慕慕子

2020-03-02

同学你好,代码是正确的,继续加油, 祝学习愉快~

0

0 学习 · 6815 问题

查看课程