Commit cce45f15 authored by Zéfling's avatar Zéfling 🎨
Browse files

fix alpha calculation for toHEX()

parent f3346e54
......@@ -219,7 +219,7 @@ export class Coloration {
toHEX(): string {
return this.calcColor ? this.value<string>(
() => '#' + (0x1000000 + this.calcColor.intColor).toString(16).slice(1)
+ (this.calcColor.alpha < 1 ? (0x100 + Math.round(this.calcColor.alpha * 256)).toString(16).slice(1) : '')
+ (this.calcColor.alpha < 1 ? (0x100 + Math.round(this.calcColor.alpha * 255)).toString(16).slice(1) : '')
) : null;
}
......@@ -283,7 +283,7 @@ export class Coloration {
? matchHex[5]
: (matchHex[3] ? matchHex[3][1] + matchHex[3][1] : undefined);
intColor = parseInt(hexaColor, 16);
alpha = hexaAlpha !== undefined ? parseInt(hexaAlpha, 16) / 256 : 1;
alpha = hexaAlpha !== undefined ? parseInt(hexaAlpha, 16) / 255 : 1;
}
if (intColor === undefined) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment