Added support for relative positioning of gradient fills. Addressed some PR feedback.

This commit is contained in:
shan 2022-10-07 11:41:50 -07:00
parent f9a6efcaa0
commit 12a87c54eb
8 changed files with 182 additions and 54 deletions

View file

@ -28,7 +28,7 @@ pub use stroke::{LineCap, LineDash, LineJoin, Stroke};
pub use text::Text;
use crate::{Backend, Primitive, Renderer};
pub use crate::gradient::Gradient;
pub use crate::gradient::{Gradient, Position, Location};
use iced_native::layout::{self, Layout};
use iced_native::mouse;

View file

@ -1,4 +1,4 @@
use lyon::geom::euclid::Vector2D;
use lyon::geom::euclid::Point2D;
use std::borrow::Cow;
use iced_native::{Point, Rectangle, Size, Vector};
@ -38,11 +38,11 @@ pub(crate) struct Transform {
impl Transform {
/// Transforms the given [Point] by the transformation matrix.
pub(crate) fn apply_to(&self, mut point: Point) -> Point {
pub(crate) fn transform_point(&self, mut point: Point) -> Point {
let transformed =
self.raw.transform_vector(Vector2D::new(point.x, point.y));
point.x = transformed.x + self.raw.m31;
point.y = transformed.y + self.raw.m32;
self.raw.transform_point(Point2D::new(point.x, point.y));
point.x = transformed.x;
point.y = transformed.y;
point
}
}