Axis-aware coordinate helpers on Point, Vec2, Size, and Rect - #592
Axis-aware coordinate helpers on Point, Vec2, Size, and Rect#592waywardmonkeys wants to merge 1 commit into
Point, Vec2, Size, and Rect#592Conversation
DJMcNab
left a comment
There was a problem hiding this comment.
I do want to make sure that we've thought about these names, because none of them particularly spark joy. Even if the response to each question is just "I can't think of anything better", that's reasonable.
This really just continues the existing naming scheme from the previously added methods of this flavour. Looking back on them, those names are not something I'm hugely happy with. At least this is consistent
| /// assert_eq!(point, Point::new(2.0, 5.0)); | ||
| /// ``` | ||
| #[inline] | ||
| pub const fn with_coord(self, axis: Axis, value: f64) -> Point { |
There was a problem hiding this comment.
What do you think about a name like snap_to_coord. That name also doesn't quite have the right ring to it, but I find that with_coord is a name which really leans on the docs to explain it.
| /// assert_eq!(rect.min_coord(Axis::Vertical), 2.0); | ||
| /// ``` | ||
| #[inline] | ||
| pub const fn min_coord(&self, axis: Axis) -> f64 { |
There was a problem hiding this comment.
If I read this name in a vacuum, I'd expect it to be (self.min_x(), self.min_y()). Especially since that method doesn't exist, the idea of adding it with these semantics at least gives me pause.
There was a problem hiding this comment.
Since this is an axis-specific method, one option might be min_along / max_along ...
| /// assert_eq!(rect, Rect::new(10.0, 2.0, 3.0, 7.0)); | ||
| /// ``` | ||
| #[inline] | ||
| pub const fn with_coords(self, axis: Axis, v0: f64, v1: f64) -> Rect { |
There was a problem hiding this comment.
Does a name like with_extents make sense to you? That feels a little bit too jargony. Wow, what a fine line naming things has...
There was a problem hiding this comment.
Yeah. This is not the first version of this PR that I've written. Perhaps the third, all with different names!
I agree on both counts. The names don't really spark joy, but neither have any others that I've come up with. I'm happy for this to take a short period of time to see if we can find better names. |
|
Also agree that these are helpful additions but the names don't spark joy. In Taffy I have used |
No description provided.