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

Difference in frame.fill behavior from 0.1.1 to master branch #446

Closed
arctic-alpaca opened this issue Jul 10, 2020 · 2 comments
Closed

Difference in frame.fill behavior from 0.1.1 to master branch #446

arctic-alpaca opened this issue Jul 10, 2020 · 2 comments
Labels
question Further information is requested
Milestone

Comments

@arctic-alpaca
Copy link

Hello,

I switched from version 0.1.1 from crates.io to the master branch. While using 0.1.1 the following code created a triangle on a canvas, with the master branch version, nothing gets drawn. I couldn't find any changes/PRs that implied this change was intended. Drawing a triangle with predefined points worked on both versions. The arrow_triangle is identical in both version if output via println! so I assume the behavior change comes from frame.fill.

let arrow_triangle = Path::new(|path| {
            path.move_to(Point::new(self.axis_origin.x + self.x_axis_length, self.axis_origin.y));
            path.line_to(Point::new(self.axis_origin.x + self.x_axis_length, self.axis_origin.y + self.axis_width * 1.5));
            path.line_to(Point::new(self.axis_origin.x + self.x_axis_length + self.axis_width * 1.5, self.axis_origin.y));
            path.line_to(Point::new(self.axis_origin.x + self.x_axis_length, self.axis_origin.y - self.axis_width * 1.5));
            path.line_to(Point::new(self.axis_origin.x + self.x_axis_length, self.axis_origin.y));
        });
        frame.fill(&arrow_triangle, Color::BLACK);

I tried to create somewhat minimal examples with both version here:

0.1.1:
https://github.com/arctic-alpaca/iced-path-problem-minimal-v0.1

master branch:
https://github.com/arctic-alpaca/iced-path-problem-minimal-github-version

Is this intended? If so, how can I draw the same on the master branch?

@hecrj
Copy link
Member

hecrj commented Jul 10, 2020

The main issue here is that you are drawing outside of the Canvas boundaries (the gray box):

image

We clip geometry outside of Canvas boundaries since #325.

The visible drawable region of a Canvas has (0, 0) at the top-left corner. For instance, you can fill a Canvas with:

frame.fill_rectangle(Point::ORIGIN, frame.size(), Color::BLACK);

In your particular example, I imagine you need to either increase the size of the Canvas or change the axis_origin value.

@hecrj hecrj added the question Further information is requested label Jul 10, 2020
@hecrj hecrj added this to the 0.2.0 milestone Jul 10, 2020
@arctic-alpaca
Copy link
Author

Oh, you're right.

When I started out with v0.1.1 I realized the borders weren't clipping so I didn't bother with it in favor of getting something rudimentary displayed. After switching I didn't think of it anymore.

I'm sorry I bothered you with such a trivial issue. Thanks for the quick response and this crate, it's a joy to work with. What's the best way to find changes between v0.1.1 and the current master branch? Checking the milestone for completed issues/merges?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants