From 22ab80e92bd702720fd2403182f6f59f540ee250 Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Wed, 21 Aug 2019 15:06:56 +0100 Subject: [PATCH] refactor(hdom-canvas): update resolveColor to use resolveAsCSS --- packages/hdom-canvas/src/draw/color.ts | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/hdom-canvas/src/draw/color.ts b/packages/hdom-canvas/src/draw/color.ts index 6f61522394..e5b6916866 100644 --- a/packages/hdom-canvas/src/draw/color.ts +++ b/packages/hdom-canvas/src/draw/color.ts @@ -1,20 +1,15 @@ -import { isArrayLike, isNumber, isString } from "@thi.ng/checks"; -import { asCSS, ColorMode, ReadonlyColor } from "@thi.ng/color"; +import { isString } from "@thi.ng/checks"; +import { resolveAsCSS } from "@thi.ng/color"; import { DrawState } from "../api"; -const resolve = (v: any) => - isArrayLike(v) - ? isNumber((v).mode) - ? asCSS(v) - : asCSS(v, ColorMode.RGBA) - : isNumber(v) - ? asCSS(v, ColorMode.INT32) - : v; - -export const resolveColor = (v: any) => (isString(v) ? v : resolve(v)); +export const resolveColor = (v: any) => (isString(v) ? v : resolveAsCSS(v)); export const resolveGradientOrColor = (state: DrawState, v: any) => - isString(v) ? (v[0] === "$" ? state.grads![v.substr(1)] : v) : resolve(v); + isString(v) + ? v[0] === "$" + ? state.grads![v.substr(1)] + : v + : resolveAsCSS(v); export const defLinearGradient = ( ctx: CanvasRenderingContext2D,