Skip to content

Commit 2462a29

Browse files
authored
Merge pull request #8 from Saspect-IO/bugfix/balancing-finalbase-for-decimal-below-16
balancing final base computation to add leading "0" for decimal value…
2 parents b121dd2 + 00f670c commit 2462a29

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ class GradientColor {
109109
let endBase = parseInt(end, 16);
110110
let average = (endBase - startBase) / midPoint;
111111
let finalBase = Math.round(average * (number - minNum) + startBase);
112-
return (finalBase.toString(16));
112+
let balancedFinalBase = finalBase < 16 ? "0" + finalBase.toString(16) : finalBase.toString(16);
113+
return balancedFinalBase;
113114
}
114115

115116
const getHexColor = props => {

0 commit comments

Comments
 (0)