CSS linear-gradient and Canvas linear-gradient aren't the same with opacity settings
问题 I want to achieve the same linear gradient look defined by CSS on a canvas. Used a method that works great until no transparency setting is used. When there are rgba color values defined with the same linear gradient color settings the results doesn't look the same, please see the following link: JSFiddle: Example var canvas = document.getElementById("myCanvas"); var ctx = document.getElementById("myCanvas").getContext("2d"); var w = canvas.width; var h = canvas.height; var cssAng = Math.PI;