This commit is contained in:
Dimitri Sabadie
2019-09-24 10:42:03 +02:00
parent 5d0ebc0777
commit 6f65be125b
10 changed files with 15 additions and 102 deletions

View File

@@ -17,7 +17,6 @@ use crate::interpolation::Interpolation;
/// key and the next one if existing. Have a look at [`Interpolation`] for further details.
///
/// [`Interpolation`]: crate::interpolation::Interpolation
#[cfg(feature = "bezier")]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serialization", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serialization", serde(rename_all = "snake_case"))]
@@ -30,36 +29,9 @@ pub struct Key<T, V> {
pub interpolation: Interpolation<T, V>
}
/// A spline control point.
///
/// This type associates a value at a given interpolation parameter value. It also contains an
/// interpolation mode used to determine how to interpolate values on the segment defined by this
/// key and the next one if existing. Have a look at [`Interpolation`] for further details.
///
/// [`Interpolation`]: crate::interpolation::Interpolation
#[cfg(not(feature = "bezier"))]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serialization", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serialization", serde(rename_all = "snake_case"))]
pub struct Key<T, V> {
/// Interpolation parameter at which the [`Key`] should be reached.
pub t: T,
/// Carried value.
pub value: V,
/// Interpolation mode.
pub interpolation: Interpolation<T>
}
impl<T, V> Key<T, V> {
/// Create a new key.
#[cfg(feature = "bezier")]
pub fn new(t: T, value: V, interpolation: Interpolation<T, V>) -> Self {
Key { t, value, interpolation }
}
/// Create a new key.
#[cfg(not(feature = "bezier"))]
pub fn new(t: T, value: V, interpolation: Interpolation<T>) -> Self {
Key { t, value, interpolation }
}
}