use super::{GradientLayerBox, GradientRamp};
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum RadialPos {
Fraction(f32),
Points(f32),
EndOffset(f32),
}
impl RadialPos {
pub fn resolve(self, extent: f32) -> f32 {
match self {
Self::Fraction(f) => extent * f,
Self::Points(p) => p,
Self::EndOffset(p) => extent - p,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RadialPoint {
pub x: RadialPos,
pub y: RadialPos,
}
impl RadialPoint {
pub const fn new(x: RadialPos, y: RadialPos) -> Self {
Self { x, y }
}
}
impl Default for RadialPoint {
fn default() -> Self {
Self::new(RadialPos::Fraction(0.5), RadialPos::Fraction(0.5))
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct RadialVector {
pub x: RadialPos,
pub y: RadialPos,
}
impl RadialVector {
pub const fn new(x: RadialPos, y: RadialPos) -> Self {
Self { x, y }
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum RadialShape {
Circle,
#[default]
Ellipse,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum RadialExtent {
ClosestSide,
ClosestCorner,
FarthestSide,
#[default]
FarthestCorner,
}
#[derive(Debug, Clone)]
pub struct RadialGradient {
pub ramp: GradientRamp,
pub center: RadialPoint,
pub shape: RadialShape,
pub extent: RadialExtent,
pub radius: Option<f32>,
pub radii: Option<RadialVector>,
pub layer_box: GradientLayerBox,
}
#[derive(Debug, Clone)]
pub struct ConicGradient {
pub from_angle: f32,
pub center: RadialPoint,
pub ramp: GradientRamp,
pub layer_box: GradientLayerBox,
}