pub struct Curve2DNorm { /* private fields */ }Expand description
A normalized 2D curve for transfer functions and easing curves.
Both x and y values are in the range [0.0, 1.0].
§Usage
Use sample(x) to get the y-value at any x position:
use plottery_project::Curve2DNorm;
let curve = Curve2DNorm::default();
let y = curve.sample(0.5);Implementations§
Source§impl Curve2DNorm
impl Curve2DNorm
pub fn new(y_first: f32, points: Vec<V2>, y_last: f32) -> Self
pub fn iter_points(&self) -> impl Iterator<Item = V2> + '_
pub fn len(&self) -> usize
Sourcepub fn sample(&self, x: f32) -> f32
pub fn sample(&self, x: f32) -> f32
Sample the curve at position x.
Returns the y-value at the given x position using linear interpolation. Input x is clamped to [0.0, 1.0].
pub fn add_point(&mut self, point: V2) -> Result<()>
pub fn remove_point_at(&mut self, index: usize) -> Result<()>
pub fn update_endpoint(&mut self, is_first: bool, y: f32)
pub fn update_point_y_norm(&mut self, index: usize, y: f32) -> Result<()>
pub fn update_point_norm( &mut self, index: usize, new_loc_norm: V2, ) -> Result<()>
Trait Implementations§
Source§impl Clone for Curve2DNorm
impl Clone for Curve2DNorm
Source§fn clone(&self) -> Curve2DNorm
fn clone(&self) -> Curve2DNorm
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Curve2DNorm
impl Debug for Curve2DNorm
Source§impl Default for Curve2DNorm
impl Default for Curve2DNorm
Source§impl<'de> Deserialize<'de> for Curve2DNorm
impl<'de> Deserialize<'de> for Curve2DNorm
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for Curve2DNorm
impl PartialEq for Curve2DNorm
Source§fn eq(&self, other: &Curve2DNorm) -> bool
fn eq(&self, other: &Curve2DNorm) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for Curve2DNorm
impl Serialize for Curve2DNorm
impl StructuralPartialEq for Curve2DNorm
Auto Trait Implementations§
impl Freeze for Curve2DNorm
impl RefUnwindSafe for Curve2DNorm
impl Send for Curve2DNorm
impl Sync for Curve2DNorm
impl Unpin for Curve2DNorm
impl UnsafeUnpin for Curve2DNorm
impl UnwindSafe for Curve2DNorm
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more