Ich bin ein einfaches Web-Diagramm mit chart.js einrichten. Bei einem hexadezimalen Farbwert wie C8C8C8
möchte ich rgba(200, 200, 200, x)
erhalten. Die x
wird als zweite Variable übergeben. Mein Code sieht wie folgt aus:jQuery konvertieren hex in rgba
function colorconvert(color, transparency) {
var r = parseInt(color.substring(0,2),16);
var g = parseInt(color.substring(2,4),16);
var b = parseInt(color.substring(4,6),16);
var a = parseInt(transparency);
return ('rgba(r, g, b, a)');
}
Aber Chrome Dev-Konsole protokolliert den Fehler:
Uncaught Error: Unable to parse color from string "rgba(r, g, b, a)"
Was mache ich falsch? Jede Hilfe wird geschätzt!
zurückkehren finden [Hexa zu rgba konvertieren] (http://stackoverflow.com/questions/21646738/convert-hex-to -rgba) –
Beispiel hier: http://www.javascripter.net/faq/hextorgb.htm – Kyle