diff options
author | 2022-10-06 16:57:38 -0700 | |
---|---|---|
committer | 2022-10-06 18:59:54 -0700 | |
commit | 9c7bf417ac9c1ac72bcc55aa3cd5e8eb962243a2 (patch) | |
tree | 9e6b027d45bf858b8ed00d1e9285bdbcffb3b6e8 /graphics/src/gradient.rs | |
parent | f4878a1a66a2e95e9430a8ccee8da823d2cb17ff (diff) | |
download | iced-9c7bf417ac9c1ac72bcc55aa3cd5e8eb962243a2.tar.gz iced-9c7bf417ac9c1ac72bcc55aa3cd5e8eb962243a2.tar.bz2 iced-9c7bf417ac9c1ac72bcc55aa3cd5e8eb962243a2.zip |
Added support for gradients to respect current frame transform.
Diffstat (limited to 'graphics/src/gradient.rs')
-rw-r--r-- | graphics/src/gradient.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/graphics/src/gradient.rs b/graphics/src/gradient.rs index 13600fb9..683a7413 100644 --- a/graphics/src/gradient.rs +++ b/graphics/src/gradient.rs @@ -1,9 +1,10 @@ //! For creating a Gradient. mod linear; -use iced_native::Color; pub use crate::gradient::linear::Linear; +use crate::widget::canvas::frame::Transform; use crate::Point; +use iced_native::Color; #[derive(Debug, Clone, PartialEq)] /// A fill which transitions colors progressively along a direction, either linearly, radially (TBD), @@ -28,4 +29,15 @@ impl Gradient { pub fn linear(start: Point, end: Point) -> linear::Builder { linear::Builder::new(start, end) } + + /// Modifies the start & end stops of the gradient to have a proper transform value. + pub(crate) fn transform(mut self, transform: &Transform) -> Self { + match &mut self { + Gradient::Linear(linear) => { + linear.start = transform.apply_to(linear.start); + linear.end = transform.apply_to(linear.end); + } + } + self + } } |