summaryrefslogtreecommitdiffstats
path: root/tiny_skia/src/canvas.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-03-01 21:47:15 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2023-03-01 21:47:15 +0100
commit838fd96212b14f20fe2224c4844904a8995f2db7 (patch)
tree10ee2b0d22dfde930b829f8ad1e4b111e7464b7c /tiny_skia/src/canvas.rs
parent5c0427edbb4358896412c736af2f441c12601d1b (diff)
downloadiced-838fd96212b14f20fe2224c4844904a8995f2db7.tar.gz
iced-838fd96212b14f20fe2224c4844904a8995f2db7.tar.bz2
iced-838fd96212b14f20fe2224c4844904a8995f2db7.zip
Disable `anti_alias` for `Frame::fill_rectangle` in `iced_tiny_skia`
Diffstat (limited to 'tiny_skia/src/canvas.rs')
-rw-r--r--tiny_skia/src/canvas.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/tiny_skia/src/canvas.rs b/tiny_skia/src/canvas.rs
index c3b8b316..59765f59 100644
--- a/tiny_skia/src/canvas.rs
+++ b/tiny_skia/src/canvas.rs
@@ -44,7 +44,7 @@ impl Frame {
self.primitives.push(Primitive::Fill {
path,
- paint: into_paint(fill.style),
+ paint: into_paint(fill.style, true),
rule: into_fill_rule(fill.rule),
transform: self.transform,
});
@@ -56,7 +56,15 @@ impl Frame {
size: Size,
fill: impl Into<Fill>,
) {
- self.fill(&Path::rectangle(top_left, size), fill);
+ let path = convert_path(&Path::rectangle(top_left, size));
+ let fill = fill.into();
+
+ self.primitives.push(Primitive::Fill {
+ path,
+ paint: into_paint(fill.style, false),
+ rule: into_fill_rule(fill.rule),
+ transform: self.transform,
+ });
}
pub fn stroke<'a>(&mut self, path: &Path, stroke: impl Into<Stroke<'a>>) {
@@ -66,7 +74,7 @@ impl Frame {
self.primitives.push(Primitive::Stroke {
path,
- paint: into_paint(stroke.style),
+ paint: into_paint(stroke.style, true),
stroke: skia_stroke,
transform: self.transform,
});
@@ -199,7 +207,7 @@ fn convert_path(path: &Path) -> tiny_skia::Path {
.expect("Convert lyon path to tiny_skia path")
}
-pub fn into_paint(style: Style) -> tiny_skia::Paint<'static> {
+pub fn into_paint(style: Style, anti_alias: bool) -> tiny_skia::Paint<'static> {
tiny_skia::Paint {
shader: match style {
Style::Solid(color) => tiny_skia::Shader::SolidColor(
@@ -238,7 +246,7 @@ pub fn into_paint(style: Style) -> tiny_skia::Paint<'static> {
.expect("Create linear gradient"),
},
},
- anti_alias: true,
+ anti_alias,
..Default::default()
}
}