Function desaturateColor

  • Convert any 24-bit RGB color to its perceptual grey equivalent using the standard luminance coefficients (Y = 0.299·R + 0.587·G + 0.114·B).

    Parameters

    • hex: number

    Returns number

    Used by every amenity sprite (shop card, grocery item, car) when the item's sale.status === 'sold'. Replacing original fills with the desaturated grey is the first step of the sold visual treatment; drawSoldBadge then paints the red SOLD banner on top.

    The function is bit-pure: it accepts a 0xRRGGBB integer and returns a 0xGGGGGG integer, so it composes cleanly with pixi.js color params.

    const grey = desaturateColor(0xff3344);
    // grey = 0x6e6e6e (approximate)