Closed fogarecious closed 6 months ago
In the clock example, seconds hand disappears when pointing at 0, 15, 30, and 45.
It seems that Path::line will not be drawn when the line is horizontal or vertical. The following code shows this:
use iced::{ mouse, widget::{ canvas::{Frame, Geometry, Path, Program, Stroke}, Canvas, }, Color, Length, Rectangle, Renderer, Sandbox, Settings, Theme, }; fn main() -> iced::Result { MyApp::run(Settings::default()) } struct MyApp; impl Sandbox for MyApp { type Message = (); fn new() -> Self { Self } fn title(&self) -> String { "".into() } fn update(&mut self, _message: Self::Message) {} fn view(&self) -> iced::Element<'_, Self::Message> { Canvas::new(MyProgram) .width(Length::Fill) .height(Length::Fill) .into() } } struct MyProgram; impl<Message> Program<Message> for MyProgram { type State = (); fn draw( &self, _state: &Self::State, renderer: &Renderer, _theme: &Theme, bounds: Rectangle, _cursor: mouse::Cursor, ) -> Vec<Geometry> { let mut frame = Frame::new(renderer, bounds.size()); frame.stroke( &Path::line([0.0, 100.0].into(), [1024.0, 100.0].into()), Stroke { style: Color::BLACK.into(), width: 50.0, ..Default::default() }, ); vec![frame.into_geometry()] } }
However, if we change the code from
&Path::line([0.0, 100.0].into(), [1024.0, 100.0].into()),
to
&Path::line([0.0, 100.0].into(), [1024.0, 101.0].into()),
i.e., move the endpoint down a little bit, then the line is drawn as expected.
Path::line is drawn for all directions including vertical and horizontal.
master
macOS
No response
Thanks for the report! This is a problem in iced_tiny_skia. #2282 should fix it.
iced_tiny_skia
Is there an existing issue for this?
Is this issue related to iced?
What happened?
In the clock example, seconds hand disappears when pointing at 0, 15, 30, and 45.
It seems that Path::line will not be drawn when the line is horizontal or vertical. The following code shows this:
However, if we change the code from
to
i.e., move the endpoint down a little bit, then the line is drawn as expected.
What is the expected behavior?
Path::line is drawn for all directions including vertical and horizontal.
Version
master
Operating System
macOS
Do you have any log output?
No response