From f2ffafbd10a26489539db0fdd2cee1201f8b8528 Mon Sep 17 00:00:00 2001 From: Derek Kniffin Date: Wed, 21 Dec 2016 21:31:30 -0500 Subject: [PATCH] Fix a bug related to the alpha hex calculation (#1048) --- app/utils/to-electron-background-color.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/utils/to-electron-background-color.js b/app/utils/to-electron-background-color.js index 4203d3e8..f086b3ca 100644 --- a/app/utils/to-electron-background-color.js +++ b/app/utils/to-electron-background-color.js @@ -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); };