diff --git a/packages/color/src/defcolor.ts b/packages/color/src/defcolor.ts index 19fe18206d..d4fe95ca83 100644 --- a/packages/color/src/defcolor.ts +++ b/packages/color/src/defcolor.ts @@ -30,7 +30,7 @@ import type { } from "./api"; import { convert, defConversions } from "./convert"; import { parseCss } from "./css/parse-css"; -import { int32Rgb } from "./int/int-rgba"; +import { int32Rgb } from "./int/int-rgb"; import { ensureArgs } from "./internal/ensure-args"; type $DefColor = { @@ -62,7 +62,7 @@ export const defColor = ( const maxR = set([], max); minR[numChannels - 1] = 1; - const $clazz = class implements TypedColor<$DefColor> { + const $Color = class implements TypedColor<$DefColor> { buf: Color; offset: number; stride: number; @@ -92,15 +92,15 @@ export const defColor = ( } copy(): $DefColor { - return new $clazz(this.deref()); + return new $Color(this.deref()); } copyView(): $DefColor { - return new $clazz(this.buf, this.offset, this.stride); + return new $Color(this.buf, this.offset, this.stride); } empty(): $DefColor { - return new $clazz(); + return new $Color(); } deref() { @@ -128,11 +128,11 @@ export const defColor = ( } }; - declareIndices($clazz.prototype, order); + declareIndices($Color.prototype, order); defConversions(spec); const fromColor = (src: ReadonlyColor, mode: ColorMode, xs: any[]): any => { - const res = new $clazz(...xs); + const res = new $Color(...xs); return mode !== spec.mode ? convert(res, src, spec.mode, mode) : res.set(src); @@ -140,18 +140,18 @@ export const defColor = ( const factory = (src?: MaybeColor, ...xs: any[]): $DefColor => src == null - ? new $clazz() + ? new $Color() : isString(src) ? factory(parseCss(src), ...xs) : isArrayLike(src) ? isString((src).mode) ? fromColor(src, (src).mode, xs) - : new $clazz(src, ...xs) + : new $Color(src, ...xs) : implementsFunction(src, "deref") ? fromColor((>src).deref(), (src).mode, xs) : isNumber(src) ? xs.length && xs.every(isNumber) - ? new $clazz(...ensureArgs([src, ...xs])) + ? new $Color(...ensureArgs([src, ...xs])) : fromColor(int32Rgb([], src), "rgb", xs) : illegalArgs(`can't create a ${spec.mode} color from: ${src}`); @@ -160,7 +160,7 @@ export const defColor = ( buf?: Color, idx?: number, stride?: number - ) => new $clazz(buf, idx, stride).randomize(rnd); + ) => new $Color(buf, idx, stride).randomize(rnd); factory.mapBuffer = ( buf: FloatArray, @@ -168,7 +168,7 @@ export const defColor = ( start = 0, cstride = 1, estride = numChannels - ) => mapStridedBuffer($clazz, buf, num, start, cstride, estride); + ) => mapStridedBuffer($Color, buf, num, start, cstride, estride); return >>factory; };