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

Artefacts at the end of moving canvas::Path::lines #2638

Open
4 tasks done
carlhammann opened this issue Oct 14, 2024 · 0 comments
Open
4 tasks done

Artefacts at the end of moving canvas::Path::lines #2638

carlhammann opened this issue Oct 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@carlhammann
Copy link

Is your issue REALLY a bug?

  • My issue is indeed a bug!
  • I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

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?

Hello, and thanks for the great library! I encountered this while investigating #2281 (which is closed, but still seems to abide; see my comment there), but this is a separate issue.

Sometimes, the endpoints of a Path::line drawn with frame.stroke will "sweep out" some artefacts, as visible in the following recording:

recording.mp4

Also, note, in the second half of the video, that these artefacts "flicker" on redraw (which is triggered by the mouse moving).

The code:

main.rs
use iced::{
    widget::{
        canvas,
        canvas::{Frame, Geometry, Path, Program, Stroke},
        column, slider,
    },
    Element, Point, Rectangle, Renderer, Theme,
};

pub fn main() -> iced::Result {
    iced::run("", update, view)
}

fn update(state: &mut State, message: Message) {
    match message {
        Message::SetX(x) => state.x = x,
    }
}

fn view(state: &State) -> Element<Message> {
    column![
        canvas(state).height(120.0).width(200.0),
        slider(0.0..=200.0, state.x, Message::SetX)
    ]
    .into()
}

#[derive(Clone, Debug)]
enum Message {
    SetX(f32),
}

struct State {
    x: f32,
    y: f32,
}

impl Default for State {
    fn default() -> Self {
        State { x: 100.0, y: 100.0 }
    }
}

impl Program<Message> for State {
    type State = ();

    fn draw(
        &self,
        _state: &(),
        renderer: &Renderer,
        _theme: &Theme,
        bounds: Rectangle,
        _cursor: iced::mouse::Cursor,
    ) -> Vec<Geometry> {
        let mut frame = Frame::new(renderer, bounds.size());

        let origin = Point::new(0.0, 0.0);
        frame.stroke(
            &Path::line(origin, Point::new(self.x, self.y)),
            Stroke::default().with_width(8.0),
        );

        vec![frame.into_geometry()]
    }
}

What is the expected behavior?

I expect to see only a moving line.

Version

crates.io release

Operating System

Linux

Do you have any log output?

No response

@carlhammann carlhammann added the bug Something isn't working label Oct 14, 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