#2e8b57
Additive color model for displays
CIE standard, device-independent
import numpy as np
# XYZ to sRGB transformation matrix
xyz_to_rgb_matrix = np.array([
[3.2406, -1.5372, -0.4986],
[-0.9689, 1.8758, 0.0415],
[0.0557, -0.2040, 1.0570]
])
# Current XYZ values (normalized to 0-1 range)
xyz = np.array([0.0000, 0.0000, 0.0000])
# Matrix multiplication
rgb_linear = np.dot(xyz_to_rgb_matrix, xyz)
print(f"Linear RGB: {rgb_linear}")
# Gamma correction
def linear_to_srgb(c):
return 12.92 * c if c <= 0.0031308 else 1.055 * (c ** (1/2.4)) - 0.055
rgb_gamma = np.array([linear_to_srgb(c) for c in rgb_linear])
# Clamp to valid range and convert to 8-bit
rgb_final = np.clip(rgb_gamma * 255, 0, 255).astype(int)
print(f"Final RGB: {rgb_final}")
// XYZ to sRGB transformation matrix
const xyzToRgbMatrix = [
[3.2406, -1.5372, -0.4986],
[-0.9689, 1.8758, 0.0415],
[0.0557, -0.2040, 1.0570]
];
// Current XYZ values (normalized to 0-1 range)
const xyz = [0.0000, 0.0000, 0.0000];
// Matrix multiplication
const rgbLinear = [
xyz[0] * xyzToRgbMatrix[0][0] + xyz[1] * xyzToRgbMatrix[0][1] + xyz[2] * xyzToRgbMatrix[0][2],
xyz[0] * xyzToRgbMatrix[1][0] + xyz[1] * xyzToRgbMatrix[1][1] + xyz[2] * xyzToRgbMatrix[1][2],
xyz[0] * xyzToRgbMatrix[2][0] + xyz[1] * xyzToRgbMatrix[2][1] + xyz[2] * xyzToRgbMatrix[2][2]
];
// Gamma correction
const linearToSrgb = (c) => c <= 0.0031308 ? 12.92 * c : 1.055 * Math.pow(c, 1/2.4) - 0.055;
const rgbGamma = rgbLinear.map(linearToSrgb);
// Clamp and convert to 8-bit
const rgbFinal = rgbGamma.map(c => Math.max(0, Math.min(255, Math.round(c * 255))));
console.log('Final RGB:', rgbFinal);
color: rgb(46, 139, 87);
color: #2e8b57;
/* XYZ: xyz(0.000, 0.000, 0.000) */