import { xyz_cmf_wyman } from "../xyz/xyz_cmf_wyman.js";
import { xyz_to_rgb } from "../xyz/xyz_to_rgb.js";

/**
 * Color-Matching Function, for sRGB
 *
 * Prefer to integrate in XYZ space and then perform the conversion to sRGB
 *
 * @param {number[]} result
 * @param {number} wavelength_nm in nanometers (1e-9)
 * @returns {number[]} the input `result` parameter, returned for convenience
 */
export function sRGB_cmf(result, wavelength_nm) {

    xyz_cmf_wyman(result, wavelength_nm); // x̄, ȳ, z̄
    // Convert per-wavelength XYZ to per-wavelength “RGB sensitivities”

    xyz_to_rgb(result, result);
    // result now holds R̄, Ḡ, B̄

    return result;
}