use*_*726 11 javascript html5 gradient canvas draw
如何绘制渐弱渐变的圆圈?
我的意思是这样的:
变暗和变暗......
小智 23
您想要使用该ctx.createRadialGradient()方法.
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var x = 100,
y = 75,
// Radii of the white glow.
innerRadius = 5,
outerRadius = 70,
// Radius of the entire circle.
radius = 60;
var gradient = ctx.createRadialGradient(x, y, innerRadius, x, y, outerRadius);
gradient.addColorStop(0, 'white');
gradient.addColorStop(1, 'blue');
ctx.arc(x, y, radius, 0, 2 * Math.PI);
ctx.fillStyle = gradient;
ctx.fill();
Run Code Online (Sandbox Code Playgroud)
示例: http ://jsfiddle.net/razh/sA6Wc/
| 归档时间: |
|
| 查看次数: |
15135 次 |
| 最近记录: |