diff --git a/packages/pixel/src/format.ts b/packages/pixel/src/format.ts index d588cae55f..af1594bdbb 100644 --- a/packages/pixel/src/format.ts +++ b/packages/pixel/src/format.ts @@ -1,4 +1,4 @@ -import { assert, IObjectOf, NumericArray, Type } from "@thi.ng/api"; +import { assert, FnN, FnN2, IObjectOf, NumericArray, Type } from "@thi.ng/api"; import { clamp01 } from "@thi.ng/math"; import { FloatFormat, @@ -23,9 +23,8 @@ const defChannel = ( const maskA = (mask0 << shift) >>> 0; const invMask = ~maskA >>> 0; const lane = ch.lane != null ? ch.lane : idx; - const int = (x: number) => (x >>> shift) & mask0; - const setInt = (src: number, x: number) => - (src & invMask) | ((x & mask0) << shift); + const int: FnN = (x) => (x >>> shift) & mask0; + const setInt: FnN2 = (src, x) => (src & invMask) | ((x & mask0) << shift); return { size: ch.size, abgrShift: 24 - lane * 8 - shift, @@ -207,8 +206,7 @@ export const defFloatFormat = (fmt: FloatFormatSpec) => { }; const to = (col: NumericArray, i: number) => ((col[i] * 0xff + 0.5) | 0) << chanShift[chan[i]]; - const from = (col: number, i: number) => - ((col >>> chanShift[chan[i]]) & 0xff) / 0xff; + const from: FnN2 = (col, i) => ((col >>> chanShift[chan[i]]) & 0xff) / 0xff; switch (chan.length) { case 1: if (fmt.gray) { diff --git a/packages/pixel/src/utils.ts b/packages/pixel/src/utils.ts index b9c6b2c01a..a014da6d41 100644 --- a/packages/pixel/src/utils.ts +++ b/packages/pixel/src/utils.ts @@ -1,4 +1,4 @@ -import { assert, Fn, Fn2, TypedArray, UIntArray } from "@thi.ng/api"; +import { assert, Fn, Fn2, FnN, TypedArray, UIntArray } from "@thi.ng/api"; import { clamp } from "@thi.ng/math"; import type { BlitOpts, PackedFormat, FloatFormat } from "./api"; @@ -17,7 +17,7 @@ export const ensureChannel = (fmt: PackedFormat | FloatFormat, id: number) => { return chan; }; -export const luminanceABGR = (c: number) => +export const luminanceABGR: FnN = (c) => (((c >>> 16) & 0xff) * 29 + ((c >>> 8) & 0xff) * 150 + (c & 0xff) * 76) / 255;