diff --git a/packages/core/color/color-common.ts b/packages/core/color/color-common.ts index ea584b0da..3a32fe3c9 100644 --- a/packages/core/color/color-common.ts +++ b/packages/core/color/color-common.ts @@ -69,12 +69,11 @@ export class Color implements definition.Color { } get hex(): string { - if (this.a === 0xff) { - return SHARP + ((1 << 24) + (this.r << 16) + (this.g << 8) + this.b).toString(16).slice(1); - } else { - const hex = this._argb.toString(16); - return SHARP + hex.slice(2) + hex.slice(0, 2); + let result = SHARP + ('000000' + (this._argb & 0xFFFFFF).toString(16)).slice(-6); + if (this.a !== 0xff) { + return result += ('00' + (this.a).toString(16)).slice(-2); } + return result; } get name(): string {