From d41df547569641dcc48d652a314b0d53a6951819 Mon Sep 17 00:00:00 2001 From: PeenScreeker Date: Fri, 1 Dec 2023 02:17:53 -0500 Subject: [PATCH] WIP cleanup --- scripts/util/colors.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/util/colors.ts b/scripts/util/colors.ts index 87188cf8..ea2b65de 100644 --- a/scripts/util/colors.ts +++ b/scripts/util/colors.ts @@ -9,8 +9,8 @@ type colorTuple = RgbTuple | RgbaTuple; // __brand is a compile time-only type trick to make these two incompatible, // even though they're really just `string`s. -type RgbString = string /* & { __brand: 'rgb' }*/; -type RgbaString = string /* & { __brand: 'rgba' }*/; +type RgbString = string; +type RgbaString = string; /** * Returns a string formatted: `rgb(R, G, B)` from RGB number tuple, where @@ -62,11 +62,7 @@ function rgbaStringToTuple(str: RgbaString): RgbaTuple { */ function rgbaTupleLerp(colorA: RgbaTuple, colorB: RgbaTuple, alpha: number): RgbaTuple { const interp = Math.max(Math.min(alpha, 1), 0); - const colorResult: RgbaTuple = [0, 0, 0, 0]; - for (let i = 0; i < 4; ++i) { - colorResult[i] = Math.round(colorA[i] + interp * (colorB[i] - colorA[i])); - } - return colorResult as RgbaTuple; + return (colorA as number[]).map((Ai, i) => Math.round(Ai + interp * (colorB[i] - Ai))) as RgbaTuple; } /**