Multiple points/colors gradient on HTML5 canvas
问题 I would like to fill a shape on a html5 canvas with a gradient created from several differents colors at different positions, like on this picture. Do you have any ideas on how I could do that? 回答1: Searching a little I have found this example from Mozilla Development Network function draw() { var ctx = document.getElementById('canvas').getContext('2d'); var radgrad = ctx.createRadialGradient(0,0,1,0,0,150); radgrad.addColorStop(0, '#A7D30C'); radgrad.addColorStop(1, 'rgba(1,159,98,0)'); var