老师 这样行吗
来源:5-2 编程练习
慕运维2135045
2018-11-10 13:22:49
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>canvas渐变</title>
</head>
<body>
<canvas id="canvas" width="600px" height="600px">您的浏览器不支持</canvas>
<script>
var canvas=document.getElementById("canvas");
var context=canvas.getContext("2d");
var gradient=context.createLinearGradient(100,100,500,500);
gradient.addColorStop(0,"red");
gradient.addColorStop(0.5,"orange");
gradient.addColorStop(1,"pink");
context.fillStyle=gradient;
context.arc(300,300,200,0,Math.PI*2,true);
context.fill();
</script>
</body>
</html>
1回答
除了颜色没太对上,效果思路是对的,颜色不重要,学会思路最重要。
继续加油!欢迎采纳!
相似问题