Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svg scaling artifacts #2307

Open
2 tasks done
EmiOnGit opened this issue Mar 2, 2024 · 0 comments
Open
2 tasks done

svg scaling artifacts #2307

EmiOnGit opened this issue Mar 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@EmiOnGit
Copy link

EmiOnGit commented Mar 2, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • 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 EmiOnGit added the bug Something isn't working label Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant