iced icon indicating copy to clipboard operation
iced copied to clipboard

svg scaling artifacts

Open EmiOnGit opened this issue 4 months ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Is this issue related to iced?

  • [X] My hardware is compatible and my graphics drivers are up-to-date.

What happened?

Problem

I'm using svg icons in my app (See code below for implementation), which I would expect to scale flawlessly. However depending on the icon I get weird artifacts as seen in the screenshot. Interestingly, the artifacts can be different for the same icon in the exact same size (see picture 3)

Pictures

image image image

The code I use to load in the icons.

pub const ICON_SIZE: f32 = 24.;

pub enum Icon {
    Trash,
    Play,
    Plus,
}
impl Icon {
    pub fn svg(&self) -> Svg {
        let handle = svg::Handle::from_memory(self.data());

        svg(handle).style(theme::Svg::custom_fn(|_theme| svg::Appearance {
            color: Some(color!(0xffffff)),
        })).width(Length::Fixed(ICON_SIZE)).height(Length::Fixed(ICON_SIZE))
    }
    const fn data(&self) -> &'static [u8] {
        match self {
            Icon::Trash => include_bytes!("../assets/feather/trash.svg"),
            Icon::Play => include_bytes!("../assets/feather/play.svg"),
            Icon::Plus => include_bytes!("../assets/feather/plus.svg"),
        }
    }
}

What is the expected behavior?

It is expected that the icons have no artifacts regardless of scaling and especially if the original size is used.

Version

crates.io release

Operating System

Linux

Do you have any log output?

No response

EmiOnGit avatar Mar 02 '24 12:03 EmiOnGit