Adds linear gradient support to 2D meshes in the canvas widget.

This commit is contained in:
shan 2022-09-29 10:52:58 -07:00
parent 97f385e093
commit 40f45d7b7e
40 changed files with 2041 additions and 655 deletions

23
graphics/src/gradient.rs Normal file
View file

@ -0,0 +1,23 @@
//! For creating a Gradient.
use iced_native::Color;
use crate::widget::canvas::gradient::Linear;
#[derive(Debug, Clone, PartialEq)]
/// A fill which transitions colors progressively along a direction, either linearly, radially,
/// or conically.
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,
}