Fix a bug related to the alpha hex calculation (#1048)

This commit is contained in:
Derek Kniffin 2016-12-21 21:31:30 -05:00 committed by Philippe Potvin
parent c7f195ba01
commit f2ffafbd10

View file

@ -8,6 +8,8 @@ module.exports = bgColor => {
if (color.alpha() === 1) {
return color.hexString();
}
// (╯°□°)╯︵ ┻━┻
return '#' + Math.floor(color.alpha() * 100) + color.hexString().substr(1);
// http://stackoverflow.com/a/11019879/1202488
const alphaHex = Math.round(color.alpha() * 255).toString(16);
return '#' + alphaHex + color.hexString().substr(1);
};