diff options
author | 2024-01-17 15:31:29 +0100 | |
---|---|---|
committer | 2024-01-17 15:31:29 +0100 | |
commit | acee3b030baf4df24a871e56789772c677b66bcf (patch) | |
tree | cc121f8d2926e547368247a63ea8c70ab9fe44bc /tiny_skia | |
parent | 4cb53a6e225f9e533126eb03d3cc34be3fd09f1d (diff) | |
download | iced-acee3b030baf4df24a871e56789772c677b66bcf.tar.gz iced-acee3b030baf4df24a871e56789772c677b66bcf.tar.bz2 iced-acee3b030baf4df24a871e56789772c677b66bcf.zip |
Fix paths with negative coordinates in `iced_tiny_skia`
Diffstat (limited to 'tiny_skia')
-rw-r--r-- | tiny_skia/src/backend.rs | 18 | ||||
-rw-r--r-- | tiny_skia/src/geometry.rs | 17 | ||||
-rw-r--r-- | tiny_skia/src/primitive.rs | 4 |
3 files changed, 21 insertions, 18 deletions
diff --git a/tiny_skia/src/backend.rs b/tiny_skia/src/backend.rs index 706db40e..d1393b4d 100644 --- a/tiny_skia/src/backend.rs +++ b/tiny_skia/src/backend.rs @@ -543,7 +543,6 @@ impl Backend { path, paint, rule, - transform, }) => { let bounds = path.bounds(); @@ -566,9 +565,11 @@ impl Backend { path, paint, *rule, - transform - .post_translate(translation.x, translation.y) - .post_scale(scale_factor, scale_factor), + tiny_skia::Transform::from_translate( + translation.x, + translation.y, + ) + .post_scale(scale_factor, scale_factor), clip_mask, ); } @@ -576,7 +577,6 @@ impl Backend { path, paint, stroke, - transform, }) => { let bounds = path.bounds(); @@ -599,9 +599,11 @@ impl Backend { path, paint, stroke, - transform - .post_translate(translation.x, translation.y) - .post_scale(scale_factor, scale_factor), + tiny_skia::Transform::from_translate( + translation.x, + translation.y, + ) + .post_scale(scale_factor, scale_factor), clip_mask, ); } diff --git a/tiny_skia/src/geometry.rs b/tiny_skia/src/geometry.rs index b00f4676..501638e0 100644 --- a/tiny_skia/src/geometry.rs +++ b/tiny_skia/src/geometry.rs @@ -40,9 +40,12 @@ impl Frame { } pub fn fill(&mut self, path: &Path, fill: impl Into<Fill>) { - let Some(path) = convert_path(path) else { + let Some(path) = + convert_path(path).and_then(|path| path.transform(self.transform)) + else { return; }; + let fill = fill.into(); self.primitives @@ -50,7 +53,6 @@ impl Frame { path, paint: into_paint(fill.style), rule: into_fill_rule(fill.rule), - transform: self.transform, })); } @@ -60,9 +62,12 @@ impl Frame { size: Size, fill: impl Into<Fill>, ) { - let Some(path) = convert_path(&Path::rectangle(top_left, size)) else { + let Some(path) = convert_path(&Path::rectangle(top_left, size)) + .and_then(|path| path.transform(self.transform)) + else { return; }; + let fill = fill.into(); self.primitives @@ -73,12 +78,13 @@ impl Frame { ..into_paint(fill.style) }, rule: into_fill_rule(fill.rule), - transform: self.transform, })); } pub fn stroke<'a>(&mut self, path: &Path, stroke: impl Into<Stroke<'a>>) { - let Some(path) = convert_path(path) else { + let Some(path) = + convert_path(path).and_then(|path| path.transform(self.transform)) + else { return; }; @@ -90,7 +96,6 @@ impl Frame { path, paint: into_paint(stroke.style), stroke: skia_stroke, - transform: self.transform, })); } diff --git a/tiny_skia/src/primitive.rs b/tiny_skia/src/primitive.rs index 0ed24969..7718d542 100644 --- a/tiny_skia/src/primitive.rs +++ b/tiny_skia/src/primitive.rs @@ -13,8 +13,6 @@ pub enum Custom { paint: tiny_skia::Paint<'static>, /// The fill rule to follow. rule: tiny_skia::FillRule, - /// The transform to apply to the path. - transform: tiny_skia::Transform, }, /// A path stroked with some paint. Stroke { @@ -24,8 +22,6 @@ pub enum Custom { paint: tiny_skia::Paint<'static>, /// The stroke settings. stroke: tiny_skia::Stroke, - /// The transform to apply to the path. - transform: tiny_skia::Transform, }, } |