1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! A gamma ramp for display color management.

use crate::bind;

/// A gamma ramp for a display.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GammaRamp(pub Box<[u16; 256]>);

impl GammaRamp {
    /// Constructs a gamma ramp from the gamma value.
    #[must_use]
    pub fn new(gamma: f32) -> Self {
        let mut ramp = Self::default();
        unsafe { bind::SDL_CalculateGammaRamp(gamma, ramp.0.as_mut_ptr()) }
        ramp
    }
}

impl Default for GammaRamp {
    fn default() -> Self {
        Self(Box::new([0; 256]))
    }
}