Added support for gradients to respect current frame transform.
This commit is contained in:
parent
f4878a1a66
commit
9c7bf417ac
7 changed files with 93 additions and 56 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue