pub struct GammaSpline { /* private fields */ }Expand description
Spline-based gamma correction curve.
Port of C++ gamma_spline from ctrl/agg_gamma_spline.h.
Takes 4 control parameters (kx1, ky1, kx2, ky2) each in [0.001..1.999]
and generates a smooth gamma curve through 4 interpolation points:
(0, 0)(kx1 * 0.25, ky1 * 0.25)(1 - kx2 * 0.25, 1 - ky2 * 0.25)(1, 1)
Produces a 256-entry lookup table (gamma()) and supports evaluation (y()).
Also implements a vertex source interface for rendering the curve.
Implementations§
Source§impl GammaSpline
impl GammaSpline
pub fn new() -> Self
Sourcepub fn set_values(&mut self, kx1: f64, ky1: f64, kx2: f64, ky2: f64)
pub fn set_values(&mut self, kx1: f64, ky1: f64, kx2: f64, ky2: f64)
Set the 4 control parameters and rebuild the spline and gamma table.
Each parameter should be in [0.001..1.999]; values are clamped.
Sourcepub fn get_values(&self) -> (f64, f64, f64, f64)
pub fn get_values(&self) -> (f64, f64, f64, f64)
Get the 4 control parameters back from the stored spline points.
Sourcepub fn y(&self, x: f64) -> f64
pub fn y(&self, x: f64) -> f64
Evaluate the spline curve at x (0..1) → result clamped to [0..1].
Trait Implementations§
Source§impl Default for GammaSpline
impl Default for GammaSpline
Source§impl GammaFunction for GammaSpline
impl GammaFunction for GammaSpline
Auto Trait Implementations§
impl !Freeze for GammaSpline
impl !RefUnwindSafe for GammaSpline
impl Send for GammaSpline
impl !Sync for GammaSpline
impl Unpin for GammaSpline
impl UnwindSafe for GammaSpline
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