From f0fa5b0a8098ad5303a2d41a9b8605f7b35c7b80 Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Sun, 6 Sep 2020 01:19:25 +0100 Subject: [PATCH] refactor(color): update types, imports --- packages/color/src/api.ts | 18 ++++++++---------- packages/color/src/clamp.ts | 2 +- packages/color/src/convert.ts | 4 ++-- packages/color/src/cosine-gradients.ts | 16 ++++++++++------ packages/color/src/css.ts | 2 +- packages/color/src/hcya-rgba.ts | 2 +- packages/color/src/hcya.ts | 2 +- packages/color/src/hsia-rgba.ts | 2 +- packages/color/src/hsia.ts | 2 +- packages/color/src/hsla-css.ts | 2 +- packages/color/src/hsla-hsva.ts | 2 +- packages/color/src/hsla-rgba.ts | 2 +- packages/color/src/hsla.ts | 2 +- packages/color/src/hsva-css.ts | 2 +- packages/color/src/hsva-hsla.ts | 2 +- packages/color/src/hsva-rgba.ts | 2 +- packages/color/src/hsva.ts | 2 +- packages/color/src/hue-rgba.ts | 2 +- packages/color/src/int-css.ts | 2 +- packages/color/src/int-rgba.ts | 4 ++-- packages/color/src/int.ts | 4 ++-- packages/color/src/internal/acolor.ts | 4 ++-- packages/color/src/internal/matrix-ops.ts | 5 ++--- packages/color/src/invert.ts | 2 +- packages/color/src/luminance-rgb.ts | 2 +- packages/color/src/luminance.ts | 2 +- packages/color/src/parse-css.ts | 4 ++-- packages/color/src/resolve.ts | 2 +- packages/color/src/rgba-css.ts | 2 +- packages/color/src/rgba-hcva.ts | 2 +- packages/color/src/rgba-hcya.ts | 2 +- packages/color/src/rgba-hsia.ts | 2 +- packages/color/src/rgba-hsla.ts | 2 +- packages/color/src/rgba-hsva.ts | 2 +- packages/color/src/rgba-int.ts | 2 +- packages/color/src/rgba-xyza.ts | 2 +- packages/color/src/rgba-ycbcra.ts | 2 +- packages/color/src/rgba.ts | 2 +- packages/color/src/srgba.ts | 2 +- packages/color/src/transform.ts | 2 +- packages/color/src/xyza-rgba.ts | 2 +- packages/color/src/xyza.ts | 2 +- packages/color/src/ycbcr.ts | 2 +- packages/color/src/ycbcra-rgba.ts | 2 +- 44 files changed, 66 insertions(+), 65 deletions(-) diff --git a/packages/color/src/api.ts b/packages/color/src/api.ts index a11ddcc574..633fb00662 100644 --- a/packages/color/src/api.ts +++ b/packages/color/src/api.ts @@ -1,19 +1,17 @@ -import { ColorMode } from "./constants"; +import type { Tuple } from "@thi.ng/api"; import type { ReadonlyVec, Vec } from "@thi.ng/vectors"; +import { ColorMode } from "./constants"; export type Color = Vec; export type ReadonlyColor = ReadonlyVec; -// prettier-ignore -export type ColorMatrix = [ - number, number, number, number, number, - number, number, number, number, number, - number, number, number, number, number, - number, number, number, number, number, -]; +/** + * A 4x5 matrix in column-major order + */ +export type ColorMatrix = Tuple; -export type CosCoeffs = [number, number, number, number]; -export type CosGradientSpec = [CosCoeffs, CosCoeffs, CosCoeffs, CosCoeffs]; +export type CosCoeffs = Tuple; +export type CosGradientSpec = Tuple; export type ColorConversion = (out: Color, src: T) => Color; export type ColorOp = (out: Color | null, src: ReadonlyColor) => Color; diff --git a/packages/color/src/clamp.ts b/packages/color/src/clamp.ts index e64c2af8b5..b61a110297 100644 --- a/packages/color/src/clamp.ts +++ b/packages/color/src/clamp.ts @@ -1,8 +1,8 @@ import { clamp01 } from "@thi.ng/math"; import { setC4 } from "@thi.ng/vectors"; +import type { Color, ReadonlyColor } from "./api"; import { ensureAlpha } from "./internal/ensure-alpha"; import { ensureHue } from "./internal/ensure-hue"; -import type { Color, ReadonlyColor } from "./api"; /** * Clamps all color channels to [0,1] interval and calls `ensureAlpha` diff --git a/packages/color/src/convert.ts b/packages/color/src/convert.ts index d1b74c494c..a3cac44143 100644 --- a/packages/color/src/convert.ts +++ b/packages/color/src/convert.ts @@ -1,5 +1,7 @@ +import type { Implementation2O, MultiFn2O } from "@thi.ng/defmulti"; import { DEFAULT, defmulti } from "@thi.ng/defmulti"; import { illegalArgs } from "@thi.ng/errors"; +import type { Color, ColorConversion, IColor, ReadonlyColor } from "./api"; import { ColorMode } from "./constants"; import { hcyaRgba } from "./hcya-rgba"; import { hsiaRgba } from "./hsia-rgba"; @@ -22,8 +24,6 @@ import { rgbaXyza } from "./rgba-xyza"; import { rgbaYcbcra } from "./rgba-ycbcra"; import { xyzaRgba } from "./xyza-rgba"; import { ycbcraRgba } from "./ycbcra-rgba"; -import type { Implementation2O, MultiFn2O } from "@thi.ng/defmulti"; -import type { Color, ColorConversion, IColor, ReadonlyColor } from "./api"; export const convert: MultiFn2O< string | number | ReadonlyColor | IColor, diff --git a/packages/color/src/cosine-gradients.ts b/packages/color/src/cosine-gradients.ts index 6ab76b4185..9cf27368b1 100644 --- a/packages/color/src/cosine-gradients.ts +++ b/packages/color/src/cosine-gradients.ts @@ -1,3 +1,4 @@ +import type { FnU2, IObjectOf } from "@thi.ng/api"; import { partial } from "@thi.ng/compose"; import { clamp01, TAU } from "@thi.ng/math"; import { @@ -8,9 +9,8 @@ import { tween, zip, } from "@thi.ng/transducers"; +import type { Color, CosCoeffs, CosGradientSpec, ReadonlyColor } from "./api"; import { clamp } from "./clamp"; -import type { IObjectOf } from "@thi.ng/api"; -import type { Color, CosGradientSpec, ReadonlyColor } from "./api"; // see http://dev.thi.ng/gradients/ - unlike the clojure version, these // presets are for RGBA (though the alpha channel is configured to @@ -157,6 +157,7 @@ export const cosineColor = (spec: CosGradientSpec, t: number): Color => clamp01(a + b * Math.cos(TAU * (c * t + d))) ), push(), + // @ts-ignore zip(...spec) ); @@ -170,13 +171,16 @@ export const cosineGradient = (n: number, spec: CosGradientSpec) => * @param from - start color * @param to - end color */ -export const cosineCoeffs = (from: ReadonlyColor, to: ReadonlyColor) => { +export const cosineCoeffs: FnU2 = ( + from, + to +) => { from = clamp([], from); to = clamp([], to); const amp = [...map(([a, b]) => 0.5 * (a - b), zip(from, to))]; - return [ - [...map(([s, a]) => s - a, zip(from, amp))], - amp, + return [ + [...map(([s, a]) => s - a, zip(from, amp))], + amp, [-0.5, -0.5, -0.5, -0.5], [0, 0, 0, 0], ]; diff --git a/packages/color/src/css.ts b/packages/color/src/css.ts index 015e039934..bdd1ad57e3 100644 --- a/packages/color/src/css.ts +++ b/packages/color/src/css.ts @@ -1,6 +1,6 @@ -import { ColorMode } from "./constants"; import type { ICopy, IDeref } from "@thi.ng/api"; import type { IColor } from "./api"; +import { ColorMode } from "./constants"; export const css = (col: string) => new CSS(col); diff --git a/packages/color/src/hcya-rgba.ts b/packages/color/src/hcya-rgba.ts index ede09b4a69..17d39287cf 100644 --- a/packages/color/src/hcya-rgba.ts +++ b/packages/color/src/hcya-rgba.ts @@ -1,9 +1,9 @@ import { clamp01 } from "@thi.ng/math"; import { dot3, setC3 } from "@thi.ng/vectors"; +import type { ColorOp } from "./api"; import { RGB_LUMINANCE } from "./constants"; import { hueRgba } from "./hue-rgba"; import { ensureAlpha } from "./internal/ensure-alpha"; -import type { ColorOp } from "./api"; export const hcyaRgba: ColorOp = (out, src) => { const h = src[0]; diff --git a/packages/color/src/hcya.ts b/packages/color/src/hcya.ts index 7b350decfc..9786d31ee0 100644 --- a/packages/color/src/hcya.ts +++ b/packages/color/src/hcya.ts @@ -1,8 +1,8 @@ import { declareIndices, IVector } from "@thi.ng/vectors"; +import type { Color } from "./api"; import { ColorMode } from "./constants"; import { AColor } from "./internal/acolor"; import { ensureArgs } from "./internal/ensure-args"; -import type { Color } from "./api"; export function hcya(col: Color, offset?: number, stride?: number): HCYA; export function hcya(h?: number, c?: number, y?: number, a?: number): HCYA; diff --git a/packages/color/src/hsia-rgba.ts b/packages/color/src/hsia-rgba.ts index 50ebaf54f2..036801a8de 100644 --- a/packages/color/src/hsia-rgba.ts +++ b/packages/color/src/hsia-rgba.ts @@ -1,6 +1,6 @@ import { setC3 } from "@thi.ng/vectors"; -import { clampH } from "./clamp"; import type { ColorOp } from "./api"; +import { clampH } from "./clamp"; // https://en.wikipedia.org/wiki/HSL_and_HSV#From_HSI diff --git a/packages/color/src/hsia.ts b/packages/color/src/hsia.ts index 3744ea9f14..8a1da88660 100644 --- a/packages/color/src/hsia.ts +++ b/packages/color/src/hsia.ts @@ -1,8 +1,8 @@ import { declareIndices, IVector } from "@thi.ng/vectors"; +import type { Color } from "./api"; import { ColorMode } from "./constants"; import { AColor } from "./internal/acolor"; import { ensureArgs } from "./internal/ensure-args"; -import type { Color } from "./api"; export function hsia(col: Color, offset?: number, stride?: number): HSIA; export function hsia(h?: number, s?: number, i?: number, a?: number): HSIA; diff --git a/packages/color/src/hsla-css.ts b/packages/color/src/hsla-css.ts index 047ae01164..23e93f52d2 100644 --- a/packages/color/src/hsla-css.ts +++ b/packages/color/src/hsla-css.ts @@ -1,8 +1,8 @@ import { clamp01 } from "@thi.ng/math"; +import type { ReadonlyColor } from "./api"; import { FF, PC } from "./constants"; import { ensureAlpha } from "./internal/ensure-alpha"; import { ensureHue } from "./internal/ensure-hue"; -import type { ReadonlyColor } from "./api"; export const hslaCss = (src: ReadonlyColor) => { const h = FF(ensureHue(src[0]) * 360); diff --git a/packages/color/src/hsla-hsva.ts b/packages/color/src/hsla-hsva.ts index 0a5dd2a7e2..6137738e6b 100644 --- a/packages/color/src/hsla-hsva.ts +++ b/packages/color/src/hsla-hsva.ts @@ -1,5 +1,5 @@ -import { clampH } from "./clamp"; import type { ColorOp } from "./api"; +import { clampH } from "./clamp"; export const hslaHsva: ColorOp = (out, src) => { out = clampH(out || src, src); diff --git a/packages/color/src/hsla-rgba.ts b/packages/color/src/hsla-rgba.ts index 4fa5964bec..b0b6f4f91b 100644 --- a/packages/color/src/hsla-rgba.ts +++ b/packages/color/src/hsla-rgba.ts @@ -1,8 +1,8 @@ import { clamp01 } from "@thi.ng/math"; import { setC3 } from "@thi.ng/vectors"; +import type { ColorOp } from "./api"; import { hueRgba } from "./hue-rgba"; import { ensureAlpha } from "./internal/ensure-alpha"; -import type { ColorOp } from "./api"; export const hslaRgba: ColorOp = (out, src) => { const s = clamp01(src[1]); diff --git a/packages/color/src/hsla.ts b/packages/color/src/hsla.ts index 3e6055a004..4bbaecbb58 100644 --- a/packages/color/src/hsla.ts +++ b/packages/color/src/hsla.ts @@ -1,8 +1,8 @@ import { declareIndices, IVector } from "@thi.ng/vectors"; +import type { Color } from "./api"; import { ColorMode } from "./constants"; import { AColor } from "./internal/acolor"; import { ensureArgs } from "./internal/ensure-args"; -import type { Color } from "./api"; export function hsla(col: Color, offset?: number, stride?: number): HSLA; export function hsla(h?: number, s?: number, l?: number, a?: number): HSLA; diff --git a/packages/color/src/hsva-css.ts b/packages/color/src/hsva-css.ts index 6919dde832..68d0f119f4 100644 --- a/packages/color/src/hsva-css.ts +++ b/packages/color/src/hsva-css.ts @@ -1,5 +1,5 @@ +import type { ReadonlyColor } from "./api"; import { hslaCss } from "./hsla-css"; import { hsvaHsla } from "./hsva-hsla"; -import type { ReadonlyColor } from "./api"; export const hsvaCss = (src: ReadonlyColor) => hslaCss(hsvaHsla([], src)); diff --git a/packages/color/src/hsva-hsla.ts b/packages/color/src/hsva-hsla.ts index 093b8c1937..bbec94cb6e 100644 --- a/packages/color/src/hsva-hsla.ts +++ b/packages/color/src/hsva-hsla.ts @@ -1,5 +1,5 @@ -import { clampH } from "./clamp"; import type { ColorOp } from "./api"; +import { clampH } from "./clamp"; export const hsvaHsla: ColorOp = (out, src) => { out = clampH(out || src, src); diff --git a/packages/color/src/hsva-rgba.ts b/packages/color/src/hsva-rgba.ts index ecbe70eb1e..26056ad15d 100644 --- a/packages/color/src/hsva-rgba.ts +++ b/packages/color/src/hsva-rgba.ts @@ -1,7 +1,7 @@ import { setC3 } from "@thi.ng/vectors"; +import type { ColorOp } from "./api"; import { clampH } from "./clamp"; import { hueRgba } from "./hue-rgba"; -import type { ColorOp } from "./api"; export const hsvaRgba: ColorOp = (out, src) => { out = clampH(out || src, src); diff --git a/packages/color/src/hsva.ts b/packages/color/src/hsva.ts index a03f8f749a..5086cbb281 100644 --- a/packages/color/src/hsva.ts +++ b/packages/color/src/hsva.ts @@ -1,8 +1,8 @@ import { declareIndices, IVector } from "@thi.ng/vectors"; +import type { Color } from "./api"; import { ColorMode } from "./constants"; import { AColor } from "./internal/acolor"; import { ensureArgs } from "./internal/ensure-args"; -import type { Color } from "./api"; export function hsva(col: Color, offset?: number, stride?: number): HSVA; export function hsva(h?: number, s?: number, v?: number, a?: number): HSVA; diff --git a/packages/color/src/hue-rgba.ts b/packages/color/src/hue-rgba.ts index d350348d25..898f80595b 100644 --- a/packages/color/src/hue-rgba.ts +++ b/packages/color/src/hue-rgba.ts @@ -1,8 +1,8 @@ import { clamp01 } from "@thi.ng/math"; import { setC4 } from "@thi.ng/vectors"; +import type { Color } from "./api"; import { Hue } from "./constants"; import { ensureHue } from "./internal/ensure-hue"; -import type { Color } from "./api"; /** * Converts a normalized hue to RGBA with given optional `alpha` diff --git a/packages/color/src/int-css.ts b/packages/color/src/int-css.ts index a3a6076b32..649257162d 100644 --- a/packages/color/src/int-css.ts +++ b/packages/color/src/int-css.ts @@ -1,6 +1,6 @@ +import type { IDeref } from "@thi.ng/api"; import { U24 } from "@thi.ng/strings"; import { FF, INV8BIT } from "./constants"; -import type { IDeref } from "@thi.ng/api"; export const int32Css = (src: number | IDeref) => { src = typeof src === "number" ? src : src.deref(); diff --git a/packages/color/src/int-rgba.ts b/packages/color/src/int-rgba.ts index 2f12041008..829939b3fb 100644 --- a/packages/color/src/int-rgba.ts +++ b/packages/color/src/int-rgba.ts @@ -1,7 +1,7 @@ +import type { IDeref } from "@thi.ng/api"; import { setC4 } from "@thi.ng/vectors"; -import { INV8BIT } from "./constants"; import type { Color } from "./api"; -import type { IDeref } from "@thi.ng/api"; +import { INV8BIT } from "./constants"; export const int32Rgba = (out: Color | null, src: number | IDeref) => { src = typeof src === "number" ? src : src.deref(); diff --git a/packages/color/src/int.ts b/packages/color/src/int.ts index 6956639fcb..6b3ca21740 100644 --- a/packages/color/src/int.ts +++ b/packages/color/src/int.ts @@ -1,6 +1,6 @@ -import { ColorMode } from "./constants"; -import type { IColor } from "./api"; import type { ICopy, IDeref } from "@thi.ng/api"; +import type { IColor } from "./api"; +import { ColorMode } from "./constants"; /** * Returns new {@link Int32} wrapping given ARGB int. diff --git a/packages/color/src/internal/acolor.ts b/packages/color/src/internal/acolor.ts index 87f3d6d9c1..6b2c726bde 100644 --- a/packages/color/src/internal/acolor.ts +++ b/packages/color/src/internal/acolor.ts @@ -1,8 +1,8 @@ +import type { IDeref } from "@thi.ng/api"; import { EPS } from "@thi.ng/math"; import { eqDelta4, stridedValues } from "@thi.ng/vectors"; -import { ColorMode } from "../constants"; -import type { IDeref } from "@thi.ng/api"; import type { Color, IColor } from "../api"; +import { ColorMode } from "../constants"; export abstract class AColor implements IColor, IDeref { buf: Color; diff --git a/packages/color/src/internal/matrix-ops.ts b/packages/color/src/internal/matrix-ops.ts index 60138f8b88..fe77b621c0 100644 --- a/packages/color/src/internal/matrix-ops.ts +++ b/packages/color/src/internal/matrix-ops.ts @@ -1,8 +1,7 @@ import { clamp01 } from "@thi.ng/math"; -import { dotS3, dotS4 } from "@thi.ng/vectors"; -import { setC4 } from "@thi.ng/vectors"; -import { ensureAlpha } from "./ensure-alpha"; +import { dotS3, dotS4, setC4 } from "@thi.ng/vectors"; import type { Color, ColorMatrix, ReadonlyColor } from "../api"; +import { ensureAlpha } from "./ensure-alpha"; export const mulV33 = ( out: Color | null, diff --git a/packages/color/src/invert.ts b/packages/color/src/invert.ts index 72aa6201e2..f7077d0378 100644 --- a/packages/color/src/invert.ts +++ b/packages/color/src/invert.ts @@ -1,6 +1,6 @@ import { ONE3, sub3 } from "@thi.ng/vectors"; -import { clamp } from "./clamp"; import type { ColorOp } from "./api"; +import { clamp } from "./clamp"; /** * Inverts the RGB channels of an RGBA color. diff --git a/packages/color/src/luminance-rgb.ts b/packages/color/src/luminance-rgb.ts index 984e92ddff..b963c06ecd 100644 --- a/packages/color/src/luminance-rgb.ts +++ b/packages/color/src/luminance-rgb.ts @@ -1,6 +1,6 @@ import { dot3 } from "@thi.ng/vectors"; -import { RGB_LUMINANCE } from "./constants"; import type { ReadonlyColor } from "./api"; +import { RGB_LUMINANCE } from "./constants"; export const luminanceRGB = (rgb: ReadonlyColor, weights = RGB_LUMINANCE) => dot3(rgb, weights); diff --git a/packages/color/src/luminance.ts b/packages/color/src/luminance.ts index 5c5411d569..0647226262 100644 --- a/packages/color/src/luminance.ts +++ b/packages/color/src/luminance.ts @@ -1,9 +1,9 @@ import { DEFAULT, defmulti, MultiFn1O } from "@thi.ng/defmulti"; import { illegalArgs } from "@thi.ng/errors"; +import type { IColor, ReadonlyColor } from "./api"; import { ColorMode } from "./constants"; import { convert } from "./convert"; import { luminanceInt, luminanceRGB } from "./luminance-rgb"; -import type { IColor, ReadonlyColor } from "./api"; /** * Multi-method to compute relative luminance from any supported input diff --git a/packages/color/src/parse-css.ts b/packages/color/src/parse-css.ts index 66413d0749..1da5d9c746 100644 --- a/packages/color/src/parse-css.ts +++ b/packages/color/src/parse-css.ts @@ -1,12 +1,12 @@ +import type { IDeref } from "@thi.ng/api"; import { illegalArgs } from "@thi.ng/errors"; import { clamp01 } from "@thi.ng/math"; import { maybeParseFloat, maybeParseInt } from "@thi.ng/strings"; +import type { Color } from "./api"; import { INV8BIT } from "./constants"; import { hslaRgba } from "./hsla-rgba"; import { int32Rgba } from "./int-rgba"; import { CSS_NAMES } from "./names"; -import type { IDeref } from "@thi.ng/api"; -import type { Color } from "./api"; const RE_HEX = /^#?([0-9a-f]{3,8})$/i; const RE_CSS = /^(rgb|hsl)a?\(\s*([0-9.]+?),\s*([0-9.]+%?),\s*([0-9.]+%?),?\s*([0-9.]+)?\s*\)$/; diff --git a/packages/color/src/resolve.ts b/packages/color/src/resolve.ts index 78ed93e44d..2826109886 100644 --- a/packages/color/src/resolve.ts +++ b/packages/color/src/resolve.ts @@ -1,7 +1,7 @@ import { isArrayLike, isNumber } from "@thi.ng/checks"; +import type { ReadonlyColor } from "./api"; import { ColorMode } from "./constants"; import { asCSS } from "./convert"; -import type { ReadonlyColor } from "./api"; /** * Takes a color in one of the following formats and tries to convert it diff --git a/packages/color/src/rgba-css.ts b/packages/color/src/rgba-css.ts index bcfeb7c97f..0ab071cf81 100644 --- a/packages/color/src/rgba-css.ts +++ b/packages/color/src/rgba-css.ts @@ -1,8 +1,8 @@ import { clamp01 } from "@thi.ng/math"; import { U24 } from "@thi.ng/strings"; +import type { ReadonlyColor } from "./api"; import { FF } from "./constants"; import { ensureAlpha } from "./internal/ensure-alpha"; -import type { ReadonlyColor } from "./api"; export const rgbaCss = (src: ReadonlyColor) => { const r = (clamp01(src[0]) * 0xff + 0.5) | 0; diff --git a/packages/color/src/rgba-hcva.ts b/packages/color/src/rgba-hcva.ts index ee3cd23ff3..c039954e07 100644 --- a/packages/color/src/rgba-hcva.ts +++ b/packages/color/src/rgba-hcva.ts @@ -1,7 +1,7 @@ import { clamp01, EPS } from "@thi.ng/math"; import { setC3 } from "@thi.ng/vectors"; -import { clamp } from "./clamp"; import type { ColorOp } from "./api"; +import { clamp } from "./clamp"; /** * Based on: diff --git a/packages/color/src/rgba-hcya.ts b/packages/color/src/rgba-hcya.ts index ba70ebb425..b52e056450 100644 --- a/packages/color/src/rgba-hcya.ts +++ b/packages/color/src/rgba-hcya.ts @@ -1,8 +1,8 @@ import { EPS } from "@thi.ng/math"; +import type { ColorOp } from "./api"; import { hueRgba } from "./hue-rgba"; import { luminanceRGB } from "./luminance-rgb"; import { rgbaHcva } from "./rgba-hcva"; -import type { ColorOp } from "./api"; /** * Ported from: diff --git a/packages/color/src/rgba-hsia.ts b/packages/color/src/rgba-hsia.ts index cadb040c04..7b320fd6d5 100644 --- a/packages/color/src/rgba-hsia.ts +++ b/packages/color/src/rgba-hsia.ts @@ -1,7 +1,7 @@ import { atan2Abs, SQRT3, TAU, THIRD } from "@thi.ng/math"; import { setC3 } from "@thi.ng/vectors"; -import { clamp } from "./clamp"; import type { ColorOp } from "./api"; +import { clamp } from "./clamp"; // https://en.wikipedia.org/wiki/HSL_and_HSV#Hue_and_chroma diff --git a/packages/color/src/rgba-hsla.ts b/packages/color/src/rgba-hsla.ts index 9241fe810a..67acb376b9 100644 --- a/packages/color/src/rgba-hsla.ts +++ b/packages/color/src/rgba-hsla.ts @@ -1,6 +1,6 @@ import { EPS } from "@thi.ng/math"; -import { rgbaHcva } from "./rgba-hcva"; import type { ColorOp } from "./api"; +import { rgbaHcva } from "./rgba-hcva"; export const rgbaHsla: ColorOp = (out, src) => { out = rgbaHcva(out, src); diff --git a/packages/color/src/rgba-hsva.ts b/packages/color/src/rgba-hsva.ts index 1719a2ce29..52999a6b45 100644 --- a/packages/color/src/rgba-hsva.ts +++ b/packages/color/src/rgba-hsva.ts @@ -1,6 +1,6 @@ import { EPS } from "@thi.ng/math"; -import { rgbaHcva } from "./rgba-hcva"; import type { ColorOp } from "./api"; +import { rgbaHcva } from "./rgba-hcva"; export const rgbaHsva: ColorOp = (out, src) => { out = rgbaHcva(out, src); diff --git a/packages/color/src/rgba-int.ts b/packages/color/src/rgba-int.ts index 4ad854de7f..cf811dc6f7 100644 --- a/packages/color/src/rgba-int.ts +++ b/packages/color/src/rgba-int.ts @@ -1,6 +1,6 @@ import { clamp01 } from "@thi.ng/math"; -import { ensureAlpha } from "./internal/ensure-alpha"; import type { ReadonlyColor } from "./api"; +import { ensureAlpha } from "./internal/ensure-alpha"; export const rgbaInt = (src: ReadonlyColor) => (((ensureAlpha(src[3]) * 0xff + 0.5) << 24) | diff --git a/packages/color/src/rgba-xyza.ts b/packages/color/src/rgba-xyza.ts index e5c80dac28..a97eb2ce69 100644 --- a/packages/color/src/rgba-xyza.ts +++ b/packages/color/src/rgba-xyza.ts @@ -1,8 +1,8 @@ +import type { ColorOp } from "./api"; import { clamp } from "./clamp"; import { RGB_XYZ } from "./constants"; import { ensureAlpha } from "./internal/ensure-alpha"; import { mulV33 } from "./internal/matrix-ops"; -import type { ColorOp } from "./api"; /** * {@link https://en.wikipedia.org/wiki/CIE_1931_color_space} diff --git a/packages/color/src/rgba-ycbcra.ts b/packages/color/src/rgba-ycbcra.ts index 61e97d7e9f..5a017ca6aa 100644 --- a/packages/color/src/rgba-ycbcra.ts +++ b/packages/color/src/rgba-ycbcra.ts @@ -1,7 +1,7 @@ import { setC3 } from "@thi.ng/vectors"; +import type { ColorOp } from "./api"; import { clamp } from "./clamp"; import { luminanceRGB } from "./luminance-rgb"; -import type { ColorOp } from "./api"; export const rgbaYcbcra: ColorOp = (out, src) => { out = clamp(out || src, src); diff --git a/packages/color/src/rgba.ts b/packages/color/src/rgba.ts index e1eb14ea32..aad98760ee 100644 --- a/packages/color/src/rgba.ts +++ b/packages/color/src/rgba.ts @@ -1,8 +1,8 @@ import { declareIndices, IVector } from "@thi.ng/vectors"; +import type { Color } from "./api"; import { ColorMode } from "./constants"; import { AColor } from "./internal/acolor"; import { ensureArgs } from "./internal/ensure-args"; -import type { Color } from "./api"; export function rgba(col: Color, offset?: number, stride?: number): RGBA; export function rgba(r?: number, g?: number, b?: number, a?: number): RGBA; diff --git a/packages/color/src/srgba.ts b/packages/color/src/srgba.ts index 121d9e83b7..9d1f09bc73 100644 --- a/packages/color/src/srgba.ts +++ b/packages/color/src/srgba.ts @@ -1,7 +1,7 @@ import { setC4 } from "@thi.ng/vectors"; +import type { ColorOp } from "./api"; import { SRGB_ALPHA } from "./constants"; import { ensureAlpha } from "./internal/ensure-alpha"; -import type { ColorOp } from "./api"; /** * Maps a single linear RGB channel value to sRGB. diff --git a/packages/color/src/transform.ts b/packages/color/src/transform.ts index 613d9be612..02431bf918 100644 --- a/packages/color/src/transform.ts +++ b/packages/color/src/transform.ts @@ -1,7 +1,7 @@ import { mix } from "@thi.ng/math"; +import type { ColorMatrix, ReadonlyColor } from "./api"; import { RGB_LUMINANCE, WHITE } from "./constants"; import { mulM45, mulV45 } from "./internal/matrix-ops"; -import type { ColorMatrix, ReadonlyColor } from "./api"; // https://drafts.fxtf.org/filter-effects/#feColorMatrixElement diff --git a/packages/color/src/xyza-rgba.ts b/packages/color/src/xyza-rgba.ts index 99b436ef26..564883c419 100644 --- a/packages/color/src/xyza-rgba.ts +++ b/packages/color/src/xyza-rgba.ts @@ -1,6 +1,6 @@ +import type { ColorOp } from "./api"; import { XYZ_RGB } from "./constants"; import { mulV33 } from "./internal/matrix-ops"; -import type { ColorOp } from "./api"; /** * {@link https://en.wikipedia.org/wiki/CIE_1931_color_space} diff --git a/packages/color/src/xyza.ts b/packages/color/src/xyza.ts index f7bd8485ff..dd49d16550 100644 --- a/packages/color/src/xyza.ts +++ b/packages/color/src/xyza.ts @@ -1,8 +1,8 @@ import { declareIndices, IVector } from "@thi.ng/vectors"; +import type { Color } from "./api"; import { ColorMode } from "./constants"; import { AColor } from "./internal/acolor"; import { ensureArgs } from "./internal/ensure-args"; -import type { Color } from "./api"; export function xyza(col: Color, offset?: number, stride?: number): XYZA; export function xyza(x?: number, y?: number, z?: number, a?: number): XYZA; diff --git a/packages/color/src/ycbcr.ts b/packages/color/src/ycbcr.ts index f6af88d0ff..8efe85a979 100644 --- a/packages/color/src/ycbcr.ts +++ b/packages/color/src/ycbcr.ts @@ -1,8 +1,8 @@ import { declareIndices, IVector } from "@thi.ng/vectors"; +import type { Color } from "./api"; import { ColorMode } from "./constants"; import { AColor } from "./internal/acolor"; import { ensureArgs } from "./internal/ensure-args"; -import type { Color } from "./api"; export function ycbcra(col: Color, offset?: number, stride?: number): YCbCrA; export function ycbcra(y: number, b: number, r: number, a?: number): YCbCrA; diff --git a/packages/color/src/ycbcra-rgba.ts b/packages/color/src/ycbcra-rgba.ts index 307ac6f4b9..a78fca5318 100644 --- a/packages/color/src/ycbcra-rgba.ts +++ b/packages/color/src/ycbcra-rgba.ts @@ -1,7 +1,7 @@ import { clamp01 } from "@thi.ng/math"; import { setC4 } from "@thi.ng/vectors"; -import { ensureAlpha } from "./internal/ensure-alpha"; import type { ColorOp } from "./api"; +import { ensureAlpha } from "./internal/ensure-alpha"; export const ycbcraRgba: ColorOp = (out, src) => { const y = src[0];