1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
//! Gradient specifications. use kurbo::Vec2; /// Specification of a gradient. #[derive(Clone)] pub enum Gradient { /// A linear gradient. Linear(LinearGradient), /// A radial gradient. Radial(RadialGradient), } /// Specification of a linear gradient. #[derive(Clone)] pub struct LinearGradient { /// The start point (corresponding to pos 0.0). pub start: Vec2, /// The end point (corresponding to pos 1.0). pub end: Vec2, /// The stops. /// /// There must be at least two for the gradient to be valid. pub stops: Vec<GradientStop>, } /// Specification of a radial gradient. #[derive(Clone)] pub struct RadialGradient { /// The center. pub center: Vec2, /// The offset of the origin relative to the center. pub origin_offset: Vec2, /// The radius. /// /// The circle with this radius from the center corresponds to pos 1.0. // TODO: investigate elliptical radius pub radius: f64, /// The stops (see similar field in [`LinearGradient`](#struct.LinearGradient.html)). pub stops: Vec<GradientStop>, } /// Specification of a gradient stop. #[derive(Clone)] pub struct GradientStop { /// The coordinate of the stop. pub pos: f32, /// The color at that stop. pub rgba: u32, }