html5 – 如何在HTML画布中绘制渐变线?

我正在画一条梯度的线条.画布怎么样?

解决方法

是.例:
// linear gradient from start to end of line
var grad= ctx.createLinearGradient(50,50,150,150);
grad.addColorStop(0,"red");
grad.addColorStop(1,"green");

ctx.strokeStyle = grad;

ctx.beginPath();
ctx.moveto(50,50);
ctx.lineto(150,150);

ctx.stroke();

在这里看到它:

http://jsfiddle.net/9bMPD/

相关文章

HTML5和CSS3实现3D展示商品信息的代码
利用HTML5中的Canvas绘制笑脸的代码
Html5剪切板功能的实现
如何通过HTML5触摸事件实现移动端简易进度条
Html5移动端获奖无缝滚动动画实现
关于HTML5和CSS3实现机器猫的代码