老师,这样做对吗?
来源:7-7 编程练习
沧海的雨季
2018-10-02 11:18:57
<!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.shadowOffsetX=5;
ctx.shadowOffsetY=5;
ctx.shadowColor="rgba(255,255,255,.6)";
ctx.shadowBlur=20;
ctx.arc(100,100,50,0,Math.PI*2,true);
ctx.fillStyle="orange";
ctx.fill();
ctx.beginPath();
ctx.shadowOffsetX=10;
ctx.shadowOffsetY=10;
ctx.shadowColor="white";
ctx.shadowBlur=5;
ctx.fillStyle="white";
ctx.font=" 40px sans-serif";
ctx.fillText("山高月小",700,200);
ctx.restore();
ctx.beginPath();
ctx.shadowOffsetX=2;
ctx.shadowOffsetY=2;
ctx.shadowColor="rgba(0,255,255,.6)";
ctx.shadowBlur=20;
ctx.strokeStyle="blue";
ctx.lineWidth=5;
ctx.moveTo(0, 680);
ctx.quadraticCurveTo(71, 155, 300, 680);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(280, 680);
ctx.quadraticCurveTo(350, 252, 500, 680);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(500, 680);
ctx.quadraticCurveTo(600, 50, 800, 680);
ctx.stroke();
ctx.beginPath();
ctx.moveTo(780, 680);
ctx.quadraticCurveTo(1000, 150, 1200, 680);
ctx.stroke();
</script>
</body>
</html>
1回答
你好,经测试,实现效果没有问题,继续加油!欢迎采纳。
祝学习愉快!
相似问题