fill()是什么意思
来源:5-7 编程练习
早知今日何必当初
2020-07-30 18:29:00
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>canvas渐变</title>
<style>
canvas{background-color:black;}
</style>
</head>
<body>
<canvas id="canvas" width="800px" height="800px">您的浏览器不支持</canvas>
<script>
var canvas=document.getElementById("canvas");
var context=canvas.getContext("2d");
//在此处补充代码
var exc= context.createRadialGradient(400,200,0,300,200,100);
exc.addColorStop(0,'white');
exc.addColorStop(0.2,'red');
exc.addColorStop(1,'gray');
context.fillStyle=exc;
context.arc(300,200,100,0,Math.PI*2,true);
context.fill();
</script>
</body>
</html>
2回答
同学你好,阴影效果可以通过修改addColorStop实现,如下:
另,fill() 方法填充当前的图像(路径)。默认颜色是黑色。例如:
如果我的回答帮到了你,欢迎采纳,祝学习愉快~
早知今日何必当初
提问者
2020-07-30
老师這个阴影效果怎么做的
相似问题