代码
提交代码
<canvas id="test" width="200" height="200">您的浏览器不支持canvas</canvas> <script> var a = document.getElementById("test"); var ctx = a.getContext("2d"); var Gradient = ctx.createLinearGradient(0,0,270,0); //圆心坐标是(95,70) 半径是60 Gradient.addColorStop(0,"red"); Gradient.addColorStop(1,"black"); ctx.fillStyle = Gradient; ctx.fillRect(20,20,150,100); </script>
运行结果