为什么其他两条画不出来

来源:7-7 编程练习

chenqianguan

2018-05-06 14:20:02

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style>
        canvas{background-color:#000;opacity:0.7}
    </style>
</head>
<body>
    <canvas id="canvas" width="1200px" height="1000px">
        您的浏览器不支持canvas
    </canvas>
    <script>
       
         var canvas=document.getElementById("canvas");
        var ctx=canvas.getContext("2d");
        // 在此处补充代码
		ctx.save();
		ctx.arc(150,150,50,0,2*Math.PI,true);
		ctx.fillStyle = "yellow";
		ctx.shadowOffsetX = 8;
		ctx.shadowOffsetY = 8;
		ctx.shadowColor = "rgba(255,255,255,.5)";
		ctx.shadowBlur = 15;
		ctx.fill();
		ctx.restore();
		
		ctx.lineWidth = 6;
		ctx.strokeStyle = "blue";
	    ctx.save();
	    ct.beginPath();
	
         ct.moveTo(5,400);
         ct.quadraticCurveTo(50,100,150,400);
         ct.lineWidth=10;
         ct.strokeStyle="blue";
         ct.stroke();
		ctx.lineWidth = 6;
		ctx.strokeStyle = "blue";
		
		ctx.beginPath();
		ctx.translate(300,500);
		ctx.moveTo(27, 501);
		ctx.bezierCurveTo(105, 9, 311, 21, 361, 505);
		ctx.stroke();
        
    </script>
</body>
</html>


写回答

1回答

好帮手慕糖

2018-05-07

你好,如下:这里应该是ctx哦,认真检查下代码。

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

祝学习愉快~

0
hhenqianguan
h 非常感谢!
h018-05-07
共1条回复

0 学习 · 4826 问题

查看课程