2022-09-29 10:52:58 -07:00
|
|
|
//! For creating a Gradient.
|
2022-10-05 10:49:58 -07:00
|
|
|
mod linear;
|
|
|
|
|
|
2022-09-29 10:52:58 -07:00
|
|
|
use iced_native::Color;
|
2022-10-04 18:24:46 -07:00
|
|
|
pub use crate::gradient::linear::Linear;
|
2022-09-30 10:27:00 -07:00
|
|
|
use crate::Point;
|
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`].
|
|
|
|
|
pub fn linear(start: Point, end: Point) -> linear::Builder {
|
|
|
|
|
linear::Builder::new(start, end)
|
|
|
|
|
}
|
|
|
|
|
}
|