From 042651c1b96d20b87c4363912a97db162daad23c Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Fri, 22 Mar 2024 02:59:24 +0530 Subject: [PATCH] ui: Update rgbaToHex to optionally return alpha value or not --- .../frontend/web/src/common/util/colorCodeTransformers.ts | 4 ++-- .../Invocation/fields/inputs/ColorFieldInputComponent.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/invokeai/frontend/web/src/common/util/colorCodeTransformers.ts b/invokeai/frontend/web/src/common/util/colorCodeTransformers.ts index f6e47d59e2e..835b2a3e35b 100644 --- a/invokeai/frontend/web/src/common/util/colorCodeTransformers.ts +++ b/invokeai/frontend/web/src/common/util/colorCodeTransformers.ts @@ -1,11 +1,11 @@ import type { RgbaColor } from 'react-colorful'; -export function rgbaToHex(color: RgbaColor): string { +export function rgbaToHex(color: RgbaColor, alpha: boolean = false): string { const hex = ((1 << 24) + (color.r << 16) + (color.g << 8) + color.b).toString(16).slice(1); const alphaHex = Math.round(color.a * 255) .toString(16) .padStart(2, '0'); - return `#${hex}${alphaHex}`; + return alpha ? `#${hex}${alphaHex}` : `#${hex}`; } export function hexToRGBA(hex: string, alpha: number) { diff --git a/invokeai/frontend/web/src/features/nodes/components/flow/nodes/Invocation/fields/inputs/ColorFieldInputComponent.tsx b/invokeai/frontend/web/src/features/nodes/components/flow/nodes/Invocation/fields/inputs/ColorFieldInputComponent.tsx index 545c5c40932..12f541441a8 100644 --- a/invokeai/frontend/web/src/features/nodes/components/flow/nodes/Invocation/fields/inputs/ColorFieldInputComponent.tsx +++ b/invokeai/frontend/web/src/features/nodes/components/flow/nodes/Invocation/fields/inputs/ColorFieldInputComponent.tsx @@ -61,7 +61,7 @@ const ColorFieldInputComponent = (props: FieldComponentProps