猿问

为什么画不出来圆?

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <title></title>

</head>
<style type="text/css">
    body{
        margin:0px;
        background:#000;
    }
    #canvas{
        display:block;
        background:#fff;
        width:500px;
        height:500px;
        margin:50px auto;
    }
</style>
<body>
    <canvas id="canvas">asdf</canvas>
</body>
<script>
        var cxt = canvas.getContext("2d");
        cxt.save();//保存路径
        cxt.beginPath();//开始路径
        cxt.arc(250,250,100,0,Math.PI*2,false);
        cxt.closePath();//结束路径
        cxt.fill();//填充方法
        cxt.restore();//释放路径
        // https://blog.csdn.net/cat_foursi/article/details/71543775
    </script>
</html>

慕移动3126203
浏览 1506回答 1
1回答

realwds

Script 写错了,先获取id var canvas=document.getElementById("canvas");var ctx=canvas.getContext('2d')
随时随地看视频慕课网APP
我要回答