Skip to main content

GammaSpline

Struct GammaSpline 

Source
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

Source

pub fn new() -> Self

Source

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.

Source

pub fn get_values(&self) -> (f64, f64, f64, f64)

Get the 4 control parameters back from the stored spline points.

Source

pub fn gamma(&self) -> &[u8; 256]

Get the 256-entry gamma lookup table.

Source

pub fn y(&self, x: f64) -> f64

Evaluate the spline curve at x (0..1) → result clamped to [0..1].

Source

pub fn set_box(&mut self, x1: f64, y1: f64, x2: f64, y2: f64)

Set the bounding box for vertex source rendering.

Source

pub fn rewind(&mut self, _idx: u32)

Rewind vertex source iteration.

Source

pub fn vertex(&mut self, vx: &mut f64, vy: &mut f64) -> u32

Get the next vertex of the gamma curve path.

Trait Implementations§

Source§

impl Default for GammaSpline

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl GammaFunction for GammaSpline

Source§

fn call(&self, x: f64) -> f64

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.