Adds linear gradient support to 2D meshes in the canvas widget.
This commit is contained in:
parent
97f385e093
commit
40f45d7b7e
40 changed files with 2041 additions and 655 deletions
|
|
@ -1,12 +1,14 @@
|
|||
use iced_native::Color;
|
||||
|
||||
use crate::widget::canvas::Gradient;
|
||||
|
||||
/// The style used to fill geometry.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct Fill {
|
||||
/// The color used to fill geometry.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Fill<'a> {
|
||||
/// The color or gradient of the fill.
|
||||
///
|
||||
/// By default, it is set to `BLACK`.
|
||||
pub color: Color,
|
||||
/// By default, it is set to [`FillStyle::Solid`] `BLACK`.
|
||||
pub style: FillStyle<'a>,
|
||||
|
||||
/// The fill rule defines how to determine what is inside and what is
|
||||
/// outside of a shape.
|
||||
|
|
@ -19,24 +21,33 @@ pub struct Fill {
|
|||
pub rule: FillRule,
|
||||
}
|
||||
|
||||
impl Default for Fill {
|
||||
fn default() -> Fill {
|
||||
impl <'a> Default for Fill<'a> {
|
||||
fn default() -> Fill<'a> {
|
||||
Fill {
|
||||
color: Color::BLACK,
|
||||
style: FillStyle::Solid(Color::BLACK),
|
||||
rule: FillRule::NonZero,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Color> for Fill {
|
||||
fn from(color: Color) -> Fill {
|
||||
impl<'a> From<Color> for Fill<'a> {
|
||||
fn from(color: Color) -> Fill<'a> {
|
||||
Fill {
|
||||
color,
|
||||
style: FillStyle::Solid(color),
|
||||
..Fill::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The color or gradient of a [`Fill`].
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum FillStyle<'a> {
|
||||
/// A solid color
|
||||
Solid(Color),
|
||||
/// A color gradient
|
||||
Gradient(&'a Gradient),
|
||||
}
|
||||
|
||||
/// The fill rule defines how to determine what is inside and what is outside of
|
||||
/// a shape.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue