为什么出不来
来源:5-2 编程练习
qq_七杀武曲_0
2018-03-30 18:03:03
<!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 a=context.creatLinearGradient(50,50,150,150);
a.addColorStop(0,'yellow');
a.addColorStop(1,'red');
a.addColorStop(2,'blue');
context.fillStyle=a;
context.fillRect(0,0,200,200);
</script>
</body>
</html>
1回答
小丸子爱吃菜
2018-03-30
可以参考这个代码去修改
注意参数的取值范围
祝学习愉快!
相似问题