createRadialGradient and transparency
问题 I'm playing around with createRadialGradient() on HTML5 canvas. It works like a charm, except when I'm trying to implement (semi-)transparency. I made this jsFiddle to make things hopefully clearer: http://jsfiddle.net/rfLf6/1/. function circle(x, y, r, c) { ctx.beginPath(); var rad = ctx.createRadialGradient(x, y, 1, x, y, r); rad.addColorStop(0, c); rad.addColorStop(1, 'transparent'); ctx.fillStyle = rad; ctx.arc(x, y, r, 0, Math.PI*2, false); ctx.fill(); } ctx.fillRect(0, 0, 256, 256);