Class Color
Hierarchy
- Cell<V>
- Color (View Summary)
Accessors
a
Returns this extends WritableBrand ? Writable<Num> : Num
b
Returns this extends WritableBrand ? Writable<Num> : Num
css
Returns Cell<string>
g
Returns this extends WritableBrand ? Writable<Num> : Num
luminance
Returns Num
r
Returns this extends WritableBrand ? Writable<Num> : Num
Methods
add
Parameters
- b: Val<Readonly<{ a: number; b: number; g: number; r: number }>>
Returns this
derive
lens
- lens(
this: Cell<Readonly<{ a: number; b: number; g: number; r: number }>>,
fwd: (v: T) => T,
bwd: (target: T, current: T) => T,
): thisEndomorphic lens from a
fwd/bwdpair (2-argbwdreads the source, 1-arg reconstructs it), or apply optic value(s), chaining left-to-right. A chain whose every hop isT → Tstays same-type (returnsthis); a chain that changes the value type yields a plainCellof the final view.Parameters
Returns this
- lens(
this: Cell<Readonly<{ a: number; b: number; g: number; r: number }>>,
...optics: readonly AppliedOptic<
Readonly<{ a: number; b: number; g: number; r: number }>,
Readonly<{ a: number; b: number; g: number; r: number }>,
>[],
): thisEndomorphic lens from a
fwd/bwdpair (2-argbwdreads the source, 1-arg reconstructs it), or apply optic value(s), chaining left-to-right. A chain whose every hop isT → Tstays same-type (returnsthis); a chain that changes the value type yields a plainCellof the final view.Parameters
- this: Cell<Readonly<{ a: number; b: number; g: number; r: number }>>
- ...optics: readonly AppliedOptic<
Readonly<{ a: number; b: number; g: number; r: number }>,
Readonly<{ a: number; b: number; g: number; r: number }>,
>[]
Returns this
- lens<V1>(
this: Cell<Readonly<{ a: number; b: number; g: number; r: number }>>,
optic: AppliedOptic<
Readonly<{ a: number; b: number; g: number; r: number }>,
V1,
>,
): Writable<Cell<V1>>Endomorphic lens from a
fwd/bwdpair (2-argbwdreads the source, 1-arg reconstructs it), or apply optic value(s), chaining left-to-right. A chain whose every hop isT → Tstays same-type (returnsthis); a chain that changes the value type yields a plainCellof the final view.Type Parameters
- V1
Parameters
Returns Writable<Cell<V1>>
- lens<Os extends AnyOptics>(
this: Cell<Readonly<{ a: number; b: number; g: number; r: number }>>,
...optics: Os,
): Writable<
Cell<
ChainResult<
Readonly<{ a: number; b: number; g: number; r: number }>,
Os,
>,
>,
>Endomorphic lens from a
fwd/bwdpair (2-argbwdreads the source, 1-arg reconstructs it), or apply optic value(s), chaining left-to-right. A chain whose every hop isT → Tstays same-type (returnsthis); a chain that changes the value type yields a plainCellof the final view.Type Parameters
- Os extends AnyOptics
Returns Writable<
Cell<
ChainResult<
Readonly<{ a: number; b: number; g: number; r: number }>,
Os,
>,
>,
>
lerp
merge
- merge(
this: Cell<Readonly<{ a: number; b: number; g: number; r: number }>>,
fold?: MergeFold<Readonly<{ a: number; b: number; g: number; r: number }>>,
): Cell<Readonly<{ a: number; b: number; g: number; r: number }>>Backward fan-in: forwards its parent's value unchanged; on write, folds N contributors into one value.
folddefaults to last-writer-wins.Parameters
- this: Cell<Readonly<{ a: number; b: number; g: number; r: number }>>
Optionalfold: MergeFold<Readonly<{ a: number; b: number; g: number; r: number }>>
Returns Cell<Readonly<{ a: number; b: number; g: number; r: number }>>
peek
Returns T
scale
Parameters
- k: Val<number>
Returns this
sub
Parameters
- b: Val<Readonly<{ a: number; b: number; g: number; r: number }>>
Returns this
to
Staticcoerce
Staticderive
Staticis
Staticlens
- lens<C extends AnyCellCtor, P>(
this: C,
parent: Read<P>,
fwd: (v: P) => Inner<InstanceType<C>>,
bwd: (target: Inner<InstanceType<C>>, v: P) => P,
): Writable<InstanceType<C>>Writable lens, typed to this class.
Cls.lens(parent, fwd, bwd)for one input,Cls.lens(parents, fwd, bwd)for N (a 2-argbwdreads the source, a 1-argbwdreconstructs it);Cls.lens(parent(s), optic, …)applies an optic value (pure or complement-carrying), chaining left-to-right onto this class.Type Parameters
- C extends AnyCellCtor
- P
Parameters
Returns Writable<InstanceType<C>>
- lens<C extends AnyCellCtor, P extends readonly Read<unknown>[]>(
this: C,
parents: P,
fwd: (vals: ReadValues<P>) => Inner<InstanceType<C>>,
bwd: (
target: Inner<InstanceType<C>>,
vals: ReadValues<P>,
) => BackUpdates<ReadValuesOrSkip<P>>,
): Writable<InstanceType<C>>Writable lens, typed to this class.
Cls.lens(parent, fwd, bwd)for one input,Cls.lens(parents, fwd, bwd)for N (a 2-argbwdreads the source, a 1-argbwdreconstructs it);Cls.lens(parent(s), optic, …)applies an optic value (pure or complement-carrying), chaining left-to-right onto this class.Type Parameters
- C extends AnyCellCtor
- P extends readonly Read<unknown>[]
Parameters
Returns Writable<InstanceType<C>>
- lens<C extends AnyCellCtor, P>(
this: C,
parent: Read<P>,
optic: AppliedOptic<P, Inner<InstanceType<C>>>,
): Writable<InstanceType<C>>Writable lens, typed to this class.
Cls.lens(parent, fwd, bwd)for one input,Cls.lens(parents, fwd, bwd)for N (a 2-argbwdreads the source, a 1-argbwdreconstructs it);Cls.lens(parent(s), optic, …)applies an optic value (pure or complement-carrying), chaining left-to-right onto this class.Type Parameters
- C extends AnyCellCtor
- P
Returns Writable<InstanceType<C>>
- lens<C extends AnyCellCtor, P extends readonly Read<unknown>[]>(
this: C,
parents: P,
optic: AppliedOptic<ReadValues<P>, Inner<InstanceType<C>>>,
): Writable<InstanceType<C>>Writable lens, typed to this class.
Cls.lens(parent, fwd, bwd)for one input,Cls.lens(parents, fwd, bwd)for N (a 2-argbwdreads the source, a 1-argbwdreconstructs it);Cls.lens(parent(s), optic, …)applies an optic value (pure or complement-carrying), chaining left-to-right onto this class.Type Parameters
- C extends AnyCellCtor
- P extends readonly Read<unknown>[]
Returns Writable<InstanceType<C>>
- lens<C extends AnyCellCtor, P, Os extends AnyOptics>(
this: C,
parent: Read<P>,
...optics: Os,
): ChainResult<P, Os> extends Inner<InstanceType<C>>
? Writable<InstanceType<C>>
: neverWritable lens, typed to this class.
Cls.lens(parent, fwd, bwd)for one input,Cls.lens(parents, fwd, bwd)for N (a 2-argbwdreads the source, a 1-argbwdreconstructs it);Cls.lens(parent(s), optic, …)applies an optic value (pure or complement-carrying), chaining left-to-right onto this class.Type Parameters
- C extends AnyCellCtor
- P
- Os extends AnyOptics
Returns ChainResult<P, Os> extends Inner<InstanceType<C>>
? Writable<InstanceType<C>>
: never - lens<
C extends AnyCellCtor,
P extends readonly Read<unknown>[],
Os extends AnyOptics,
>(
this: C,
parents: P,
...optics: Os,
): ChainResult<ReadValues<P>, Os> extends Inner<InstanceType<C>>
? Writable<InstanceType<C>>
: neverWritable lens, typed to this class.
Cls.lens(parent, fwd, bwd)for one input,Cls.lens(parents, fwd, bwd)for N (a 2-argbwdreads the source, a 1-argbwdreconstructs it);Cls.lens(parent(s), optic, …)applies an optic value (pure or complement-carrying), chaining left-to-right onto this class.Type Parameters
- C extends AnyCellCtor
- P extends readonly Read<unknown>[]
- Os extends AnyOptics
Returns ChainResult<ReadValues<P>, Os> extends Inner<InstanceType<C>>
? Writable<InstanceType<C>>
: never
Staticpin
Properties
Readonly_t
name
Optional debug label (cell(0, { name })); used by errors and graph dumps.
Read-only same-type view: the RO dual of the endo
.lens. For a cross-type view use the typed staticTarget.derive(src, fn).