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

WIP Use euclid crate for geometry types #1136

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Sep 19, 2023

This does not yet compile.

It seems one difference between the Euclid types and the ones Smithay currently has is that euclid's points cannot be added, and there's a seperate vector type. That is probably better for making sure code dealing with coordinates is correct. Though that will require some changes.

@ids1024 ids1024 force-pushed the euclid branch 2 times, most recently from c0afa09 to 7344ba2 Compare September 20, 2023 00:42
@@ -169,7 +169,7 @@ where
} else {
3
};
Rectangle::from_loc_and_size((0, 0), (24 * digits, 35)).to_f64()
Rectangle::new((0, 0), (24 * digits, 35)).to_f64()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is actually a rect method in euclid to make this even shorter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. I guess the cases with origin (0, 0) should just be equivalent to Rect::from_size.

@ids1024
Copy link
Member Author

ids1024 commented Sep 20, 2023

Another thing euclid doesn't have is functions like Size::to_point. But it's probably best to express things in ways other than a cast like that.

Not sure how best to make use of things like Euclid::Translation2D and Euclid::Scale for conversion between coordinate spaces.

With or without this change, Logical should be split into absolute coordinates, space-relative, surface/renderelement-relative.

This does not yet compile.

It seems one difference between the Euclid types and the ones Smithay
currently has is that `euclid`'s points cannot be added, and there's a
seperate vector type. That is probably better for making sure code
dealing with coordinates is correct. Though that will require some
changes.
@ids1024
Copy link
Member Author

ids1024 commented Sep 20, 2023

Another difference is that apparently casts in euclid like to_i32 are panicking if out of range. Unlike what Smithay has, which seems to just be using as i32. That's something to be cautious about, though casts like that are probably already problematic if there's any real situation where they can be out of range.

Probably as long as signed types are used, this would only be an issue if a client sent some extreme values.

Edit: If needed try_cast will do the cast and return an Option.

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

Successfully merging this pull request may close these issues.

None yet

2 participants