Class Box

    Hierarchy
    Index

    Accessors

    Constructors

    Methods

    • Parameters

      • b: Val<Readonly<{ h: number; w: number; x: number; y: number }>>

      Returns this

    • Vec at parametric (u, v) in [0,1]². Not memoised; use the named edge getters (.center, .top, …) for stable identity.

      Parameters

      • u: number
      • v: number

      Returns Vec

    • True when p is inside the box. A writable Vec yields a Writable<Bool>: flipping it clamps p to the nearest in-box point (true) or ejects it past the nearest edge (false). Literal/RO inputs yield a read-only Bool.

      Type Parameters

      • P extends Val<Readonly<{ x: number; y: number }>>

      Parameters

      Returns P extends WritableBrand ? Writable<Bool> : Bool

    • Read-only same-type view: the RO dual of the endo .lens. For a cross-type view use the typed static Target.derive(src, fn).

      Parameters

      • this: Cell<Readonly<{ h: number; w: number; x: number; y: number }>>
      • fn: (v: T) => T

      Returns this

    • Endomorphic lens from a fwd/bwd pair (2-arg bwd reads the source, 1-arg reconstructs it), or apply optic value(s), chaining left-to-right. A chain whose every hop is T → T stays same-type (returns this); a chain that changes the value type yields a plain Cell of the final view.

      Parameters

      • this: Cell<Readonly<{ h: number; w: number; x: number; y: number }>>
      • fwd: (v: T) => T
      • bwd: (target: T, current: T) => T

      Returns this

    • Endomorphic lens from a fwd/bwd pair (2-arg bwd reads the source, 1-arg reconstructs it), or apply optic value(s), chaining left-to-right. A chain whose every hop is T → T stays same-type (returns this); a chain that changes the value type yields a plain Cell of the final view.

      Parameters

      • this: Cell<Readonly<{ h: number; w: number; x: number; y: number }>>
      • ...optics: readonly AppliedOptic<
            Readonly<{ h: number; w: number; x: number; y: number }>,
            Readonly<{ h: number; w: number; x: number; y: number }>,
        >[]

      Returns this

    • Endomorphic lens from a fwd/bwd pair (2-arg bwd reads the source, 1-arg reconstructs it), or apply optic value(s), chaining left-to-right. A chain whose every hop is T → T stays same-type (returns this); a chain that changes the value type yields a plain Cell of the final view.

      Type Parameters

      • V1

      Parameters

      • this: Cell<Readonly<{ h: number; w: number; x: number; y: number }>>
      • optic: AppliedOptic<Readonly<{ h: number; w: number; x: number; y: number }>, V1>

      Returns Writable<Cell<V1>>

    • Endomorphic lens from a fwd/bwd pair (2-arg bwd reads the source, 1-arg reconstructs it), or apply optic value(s), chaining left-to-right. A chain whose every hop is T → T stays same-type (returns this); a chain that changes the value type yields a plain Cell of the final view.

      Type Parameters

      • Os extends AnyOptics

      Parameters

      • this: Cell<Readonly<{ h: number; w: number; x: number; y: number }>>
      • ...optics: Os

      Returns Writable<
          Cell<
              ChainResult<
                  Readonly<{ h: number; w: number; x: number; y: number }>,
                  Os,
              >,
          >,
      >

    • Parameters

      • b: Val<Readonly<{ h: number; w: number; x: number; y: number }>>
      • t: Val<number>

      Returns Box

    • Backward fan-in: forwards its parent's value unchanged; on write, folds N contributors into one value. fold defaults to last-writer-wins.

      Parameters

      • this: Cell<Readonly<{ h: number; w: number; x: number; y: number }>>
      • Optionalfold: MergeFold<Readonly<{ h: number; w: number; x: number; y: number }>>

      Returns Cell<Readonly<{ h: number; w: number; x: number; y: number }>>

    • Parameters

      • b: Val<Readonly<{ h: number; w: number; x: number; y: number }>>

      Returns this

    • Coerce Val<Inner<Cls>>Cls: instance → identity, RO cell → tracked derive, literal → fresh seed.

      Type Parameters

      • C extends AnyCellCtor

      Parameters

      Returns InstanceType<C>

    • Read-only typed view. Cls.derive(parent, fn) (1-input), Cls.derive(parents, fn) (N-input), or Cls.derive(fn) (closure). Polymorphic-this: Vec.derive(...)Vec.

      Type Parameters

      • C extends AnyCellCtor
      • P

      Parameters

      Returns InstanceType<C>

    • Read-only typed view. Cls.derive(parent, fn) (1-input), Cls.derive(parents, fn) (N-input), or Cls.derive(fn) (closure). Polymorphic-this: Vec.derive(...)Vec.

      Type Parameters

      • C extends AnyCellCtor
      • P extends readonly Read<unknown>[]

      Parameters

      • this: C
      • parents: P
      • fn: (vals: ReadValues<P>) => Inner<InstanceType<C>>

      Returns InstanceType<C>

    • Read-only typed view. Cls.derive(parent, fn) (1-input), Cls.derive(parents, fn) (N-input), or Cls.derive(fn) (closure). Polymorphic-this: Vec.derive(...)Vec.

      Type Parameters

      • C extends AnyCellCtor

      Parameters

      • this: C
      • fn: () => Inner<InstanceType<C>>

      Returns InstanceType<C>

    • Type predicate against this class: Vec.is(x) narrows x to Vec. Inherited static; works for any subclass via polymorphic this.

      Type Parameters

      • C extends AnyCellCtor

      Parameters

      • this: C
      • v: unknown

      Returns v is 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-arg bwd reads the source, a 1-arg bwd reconstructs 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

      • this: C
      • parent: Read<P>
      • fwd: (v: P) => Inner<InstanceType<C>>
      • bwd: (target: Inner<InstanceType<C>>, v: P) => P

      Returns 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-arg bwd reads the source, a 1-arg bwd reconstructs 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

      • this: C
      • parents: P
      • fwd: (vals: ReadValues<P>) => Inner<InstanceType<C>>
      • bwd: (
            target: Inner<InstanceType<C>>,
            vals: ReadValues<P>,
        ) => BackUpdates<ReadValuesOrSkip<P>>

      Returns 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-arg bwd reads the source, a 1-arg bwd reconstructs 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

      • this: C
      • parent: Read<P>
      • optic: AppliedOptic<P, Inner<InstanceType<C>>>

      Returns 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-arg bwd reads the source, a 1-arg bwd reconstructs 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

      • this: C
      • parents: P
      • optic: AppliedOptic<ReadValues<P>, Inner<InstanceType<C>>>

      Returns 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-arg bwd reads the source, a 1-arg bwd reconstructs 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

      Parameters

      Returns ChainResult<P, Os> extends Inner<InstanceType<C>>
          ? Writable<InstanceType<C>>
          : never

    • Writable lens, typed to this class. Cls.lens(parent, fwd, bwd) for one input, Cls.lens(parents, fwd, bwd) for N (a 2-arg bwd reads the source, a 1-arg bwd reconstructs 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

      Parameters

      • this: C
      • parents: P
      • ...optics: Os

      Returns ChainResult<ReadValues<P>, Os> extends Inner<InstanceType<C>>
          ? Writable<InstanceType<C>>
          : never

    • Writable-shaped constant: always reads v, absorbs writes (parentless sink lens), for APIs demanding bidirectionality.

      Type Parameters

      • C extends AnyCellCtor

      Parameters

      Returns Writable<InstanceType<C>>

    Properties

    _t: {
        equals: (a: V, b: V) => boolean;
        lerp: (a: V, b: V, t: number) => V;
        linear: Linear<Readonly<{ h: number; w: number; x: number; y: number }>>;
        metric: (a: V, b: V) => number;
        pack: Pack<Readonly<{ h: number; w: number; x: number; y: number }>>;
    }

    Type Declaration

    • equals: (a: V, b: V) => boolean
    • lerp: (a: V, b: V, t: number) => V
    • linear: Linear<Readonly<{ h: number; w: number; x: number; y: number }>>
    • metric: (a: V, b: V) => number

      Euclidean distance over (x, y, w, h).

    • pack: Pack<Readonly<{ h: number; w: number; x: number; y: number }>>
    name: string | undefined

    Optional debug label (cell(0, { name })); used by errors and graph dumps.

    value: T
    traits: {
        equals: (a: V, b: V) => boolean;
        lerp: (a: V, b: V, t: number) => V;
        linear: Linear<Readonly<{ h: number; w: number; x: number; y: number }>>;
        metric: (a: V, b: V) => number;
        pack: Pack<Readonly<{ h: number; w: number; x: number; y: number }>>;
    } = ...

    Type Declaration

    • equals: (a: V, b: V) => boolean
    • lerp: (a: V, b: V, t: number) => V
    • linear: Linear<Readonly<{ h: number; w: number; x: number; y: number }>>
    • metric: (a: V, b: V) => number

      Euclidean distance over (x, y, w, h).

    • pack: Pack<Readonly<{ h: number; w: number; x: number; y: number }>>