postcss-get-color
postcss-get-color copied to clipboard
Vibrant variant not always available
Not all variants are always available for all images, making this plugin throw error about variant not available some times for some images (Muted for example)
https://github.com/akfish/node-vibrant/pull/50
Hi @Kronuz! Currently, the plugin takes the first color in palette when variant is not available, and shows a warning message. What do you think it should be the ideal behavior in this case?
Well, the thing is if no color is found, get-color()
shows me an error and dies. For example, I was requesting get-color("image.jpeg", Muted)
and I got the error in the console saying undefined
didn' have something or such, and compilation died; the only colors available there in such object were Vibrant variations, after closer inspection.
What I think it should do is probably on the vibrant's side. It should always return colors for every swatch; no matter if there's no exact matching color; it could return the closest (which some times would include non-conformant/ugly-looking colors for the palettte), or better, from the closest it could saturate/desaturated and/or darken/lighten to match a swatch; that way I'd know a color for the palette variation I need would always be available
Ok. I agree that throw an error is not the ideal behavior, this is why I added a warning and returned the first value in palette, avoiding leave an empty value.
As you say, this problem should be solved on Vibrant's side.
If you have another suggestion, I would like to hear it!