如何去除strokeRect画矩形时的默认的线条呢?

来源:7-2 编程练习

gaogao_

2017-11-16 17:40:23

http://img.mukewang.com/climg/5a0d5cfd00012cfc06220525.jpg

写回答

3回答

小丸子爱吃菜

2017-11-16

把这些代码注释掉就可以,不需要设置

http://img.mukewang.com/climg/5a0d6c88000154f907490630.jpg

0

gaogao_

提问者

2017-11-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.beginPath();
        context.moveTo(400,400);
        context.arc(400,400,200,0,Math.PI*2,true);
        context.clip();
        
        context.strokeRect(200,200,200,200);
        context.fillStyle="#7ff9a1";
        context.fillRect(200,200,200,200);
        
        context.strokeRect(400,200,200,200);
        context.fillStyle="#7b4ab8";
        context.fillRect(400,200,200,200);

        context.strokeRect(200,400,200,200);
        context.fillStyle="#f0953c";
        context.fillRect(200,400,200,200);

        context.strokeRect(400,400,200,200);
        context.fillStyle="#e39ccc";
        context.fillRect(400,400,200,200);

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

http://img.mukewang.com/climg/5a0d5fd300018eac06730559.jpg

就是strokeRect默认给每个矩形描边了,怎么消除这种描边?

0

小丸子爱吃菜

2017-11-16

你可以将你写的代码粘贴过来,我们看下是什么情况!

祝学习愉快!

0

0 学习 · 626 问题

查看课程