@OPEN-KAPPA/COLORS
    Preparing search index...

    Class AnalogFxAbstract

    A collection of effects simulating analog video artifacts and signal errors.

    • These methods operate in the YUV color space, which separates Luminance (Y) from Chrominance (UV). This allows for manipulating color information independently from brightness, mimicking how analog TV signals (NTSC/PAL) and VHS tapes works.
    Index

    Methods

    • Simulates the Quantization Noise or low chroma bandwidth. Older digital video formats (like early JPEG or MPEG) and analog signals often had much lower resolution for color than for brightness (Chroma Subsampling). This effect rounds the U and V channels to discrete steps, creating a "banding" or "posterized" look on the colors, while keeping the details (Luminance) sharp.

      Type Parameters

      Parameters

      • color: C

        The source color to process.

      • steps: number = 6

        The number of quantization steps. - Lower values (e.g. 4-8) create strong retro artifacts. - Higher values (e.g. 32+) are subtle. - Default is 6.

      Returns C

      A new color instance with crunched chroma, in the same space of the source. *

      const color = ...
      // Reduce color precision to just 4 steps simulates 4-bit chroma
      const retro = AnalogFx.chromaCrunch(color, 4);
    • Performs an atomic Chroma Shift (Ghosting) merge. This method combines the Luminance (Y) from the baseColor with the Chrominance (UV/CbCr) from the shiftedColor. To implement a spatial glitch effect (e.g. VHS color bleeding), iterate over an image and call this method passing the pixel at (x, y) as baseColor and the pixel at (x + shift, y) as shiftedColor.

      Type Parameters

      Parameters

      • baseColor: C

        The provider of the Luminance (Detail) signal.

      • shiftedColor: C

        The provider of the Chrominance (Color) signal.

      Returns C

      A new color with the merged signals.

      If baseColor and shiftedColor are not in the same color space.

      // Simulate a 10px chroma lag
      const pixelClean = image.getPixel(x, y);
      const pixelOld = image.getPixel(x - 10, y);
      // The detail is crisp (current pixel), but color is lagging (old pixel)
      const glitch = AnalogFx.chromaShift(pixelClean, pixelOld);
    • Simulates Signal Gain Error (Saturation/Bleeding). In analog circuitry, color is transmitted as a voltage wave. If the amplifier gain is too high, colors become neon/blown-out ("Deep Fried" meme look). If the gain is too low, colors look washed out (old VHS tape). Unlike standard HSL saturation, this multiplies the UV signal vectors directly, which can push colors outside the valid gamut more aggressively and mathematically accurately to how voltage gain works.

      Type Parameters

      Parameters

      • color: C

        The source color to process.

      • gain: number

        The gain factor. - 0: Black & White. - 0.5: Washed out (Old tape). - 1.0: Original. - >1.5: Oversaturated / Neon / Blowing out.

      Returns C

      A new color instance with modified gain, in the same space of the source. *

      // Simulate a bad VHS tape with weak color signal
      const vhsLook = AnalogFx.signalGain(original, 0.6);
      * // Simulate a "Deep Fried" meme effect
      const deepFried = AnalogFx.signalGain(original, 2.5);
    • Simulates the NTSC Tint/Phase Error. In analog NTSC television, the "Hue" was determined by the phase of the color wave relative to a reference burst. Timing errors (bad cables, atmospheric interference) caused the phase to shift, rotating all colors. This rotates the UV plane by a given angle, shifting hues without affecting luminance. Typical "Green/Purple" shifts of bad TV signals can be achieved here.

      Type Parameters

      Parameters

      • color: C

        The source color to process.

      • angleDegrees: number

        The rotation angle in degrees. - Positive values shift towards purple/blue. - Negative values shift towards green/yellow.

      Returns C

      A new color instance with rotated phase, in the same space of the source. *

      // Shift colors slightly towards green (common in old TVs)
      const badTv = AnalogFx.tvTint(original, -15);