Function normalizeColorInt

  • Normalizes the size of components in the 32-bit color integer.

    normalizeColorInt(0x1, 1) // ⮕ 0x11_11_11_ff
    normalizeColorInt(0x12, 2) // ⮕ 0x12_12_12_ff
    normalizeColorInt(0x123, 3) // ⮕ 0x11_22_33_ff
    normalizeColorInt(0x1234, 4) // ⮕ 0x11_22_33_44
    normalizeColorInt(0x12345, 5) // ⮕ 0
    normalizeColorInt(0x123456, 6) // ⮕ 0x12_34_56_ff
    normalizeColorInt(0x1234567, 7) // ⮕ 0
    normalizeColorInt(0x12345678, 8) // ⮕ 0x12_34_56_78

    Parameters

    • color: number

      The input color to normalize, ex. 0xff_ff_ff for white in RGB space.

    • nibbleCount: number

      The number (1, 2, 3, 4, 6, or 8) of nibbles the input color.

    Returns number

    A valid 32-bit color integer.