pub struct ColorFromSpectrum {
pub wavelengths_nm: Vec<f64>,
pub power: Vec<f64>,
}Expand description
CIE 1931 XYZ colour space integration from a spectral power distribution.
Uses a compact 31-point tabulation (380–780 nm, 10 nm spacing) of the standard CIE 2° observer colour matching functions.
Fields§
§wavelengths_nm: Vec<f64>Wavelengths (nm) at each sample point.
power: Vec<f64>Spectral power at each sample (arbitrary units).
Implementations§
Source§impl ColorFromSpectrum
impl ColorFromSpectrum
Sourcepub fn new(wavelengths_nm: Vec<f64>, power: Vec<f64>) -> Self
pub fn new(wavelengths_nm: Vec<f64>, power: Vec<f64>) -> Self
Construct from paired wavelength/power vectors.
Lengths must be equal.
Sourcepub fn to_xyz(&self) -> (f64, f64, f64)
pub fn to_xyz(&self) -> (f64, f64, f64)
Integrate spectrum against CIE 1931 2° colour matching functions.
Returns (X, Y, Z) tristimulus values using the trapezoidal rule.
Sourcepub fn to_srgb_linear(&self) -> (f64, f64, f64)
pub fn to_srgb_linear(&self) -> (f64, f64, f64)
Convert XYZ to sRGB (D65, linear, no gamma).
Values are clamped to [0, 1].
Sourcepub fn peak_wavelength(&self) -> f64
pub fn peak_wavelength(&self) -> f64
Dominant wavelength estimate: returns the wavelength with maximum power.
Trait Implementations§
Source§impl Clone for ColorFromSpectrum
impl Clone for ColorFromSpectrum
Source§fn clone(&self) -> ColorFromSpectrum
fn clone(&self) -> ColorFromSpectrum
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ColorFromSpectrum
impl RefUnwindSafe for ColorFromSpectrum
impl Send for ColorFromSpectrum
impl Sync for ColorFromSpectrum
impl Unpin for ColorFromSpectrum
impl UnsafeUnpin for ColorFromSpectrum
impl UnwindSafe for ColorFromSpectrum
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more