2022-09-29 10:52:58 -07:00
|
|
|
//! For creating a Gradient.
|
2022-10-05 10:49:58 -07:00
|
|
|
mod linear;
|
|
|
|
|
|
2022-10-07 16:28:13 -07:00
|
|
|
pub use crate::gradient::linear::{Linear, Location, Position};
|
2022-10-07 16:55:55 -07:00
|
|
|
use crate::Color;
|
2022-09-29 10:52:58 -07:00
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
2022-09-30 10:27:00 -07:00
|
|
|
/// A fill which transitions colors progressively along a direction, either linearly, radially (TBD),
|
|
|
|
|
/// or conically (TBD).
|
2022-09-29 10:52:58 -07:00
|
|
|
pub enum Gradient {
|
|
|
|
|
/// A linear gradient interpolates colors along a direction from its [`start`] to its [`end`]
|
|
|
|
|
/// point.
|
|
|
|
|
Linear(Linear),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
|
/// A point along the gradient vector where the specified [`color`] is unmixed.
|
|
|
|
|
pub struct ColorStop {
|
|
|
|
|
/// Offset along the gradient vector.
|
|
|
|
|
pub offset: f32,
|
|
|
|
|
/// The color of the gradient at the specified [`offset`].
|
|
|
|
|
pub color: Color,
|
2022-09-30 10:27:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Gradient {
|
|
|
|
|
/// Creates a new linear [`linear::Builder`].
|
2022-10-07 11:41:50 -07:00
|
|
|
pub fn linear(position: impl Into<Position>) -> linear::Builder {
|
|
|
|
|
linear::Builder::new(position.into())
|
2022-09-30 10:27:00 -07:00
|
|
|
}
|
2022-10-07 11:41:50 -07:00
|
|
|
}
|