You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I came across the Rect type when starting on some functions which take rectangular regions such as crop(). I would like to use this type to take arguments to the crop() function. However, there are several issues I have with it at the moment that make me reluctant to go near it.
Naming: I dislike the non-intuitive left and top members which don't define which is the x and which is the y.
Visibility: Could we make the members public since this is a very simple data struct.
Data-types: I don't understand why left and top are i32 and not u32 since negative values don't make any sense in normal image coordinates. Also various Image methods take x: u32 which makes this very un-ergonomic to use.
Proposal:
May I suggest we change Rect to be defined as:
The motivation for this change was me wanting to implement crop() which would take a Rect but the current Rect is not conducive to the crop() functions requirements as described above.
crop() and similar functions are what I'm implementing as a part of image-rs/image#2238
Actually, I've just found the Rect from image which is already fits the exact pattern I'd proposed. I'm going to close this and open a different issue that changes the suggestion to migrating to image::Rect.
I came across the
Rect
type when starting on some functions which take rectangular regions such ascrop()
. I would like to use this type to take arguments to thecrop()
function. However, there are several issues I have with it at the moment that make me reluctant to go near it.Currently defined as:
left
andtop
members which don't define which is thex
and which is they
.left
andtop
arei32
and notu32
since negative values don't make any sense in normal image coordinates. Also variousImage
methods takex: u32
which makes this very un-ergonomic to use.Proposal:
May I suggest we change
Rect
to be defined as:The docs can then state that the
xy
define the top-left point of the rectangle.This also matches other
Rect
types in the rust ecosystem such as the Rectangle fromiced
.The text was updated successfully, but these errors were encountered: