def match_max_scale(
    input_colors: tuple[int, ...],
    output_colors: tuple[float, ...],
) -> tuple[int, ...]:
    """Match the maximum value of the output to the input."""
    max_in = max(input_colors)
    max_out = max(output_colors)
    factor = 0.0 if max_out == 0 else max_in / max_out
    return tuple(int(round(i * factor)) for i in output_colors)
Match the maximum value of the output to the input.
webapp/homeassistant_util_color.py