-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
var color = Spectra("rgba(255, 0, 0, 0.5)");
ctx.fillStyle = color;
console.log(Spectra(ctx.fillStyle).rgbaString()); // rgba(255,0,0,1)
I would expect the last statement to print "rgba(255,0,0,0.5)".
By far the easiest fix would be to let .toString() equal .rgbaString(). A slightly more sophisticated fix would be to let .toString equal the input type:
function l(c) {
ctx.fillStyle = c;
console.log(Spectra(ctx.fillStyle).rgbaString());
}
var c1 = Spectra("rgb(255, 0, 0)");
var c2 = Spectra("hsl(120, 100%, 50%)");
var c3 = Spectra("rgba(255, 0, 0, 0.5)");
l(c1); // "rgb(255, 0, 0)"
l(c2); // "hsl(120, 100%, 50%)");
l(c3); // "rgba(255, 0, 0, 0.5)");
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels