Comments (6)
Note that you can write let r = rect(x, y, w, h);
as a shorthand to create rects instead of Rect::new
which is indeed cumbersome. I think that it is already nicer than Rect::from_xywh
and implementing the From trait for a tuple of floats.
I'd be happy to add left
, right
, top
, bottom
, width
and height
. I am less enthused by x()
and y()
since left and top would provide the same thing in a less ambiguous ways (some libraries defines rects as a pair of points or a point at the center with width and height, etc. we even were close to change the representation in euclid at some point).
I don't think that setters are providing much (foo.set_width(w);
vs foo.origin.width = w;
). Although set_left/right/top/bottom
would provide something useful.
from euclid.
you can write let r = rect(x, y, w, h);
How it works?
Should I make a pull request?
from euclid.
See: https://docs.rs/euclid/0.17.2/euclid/fn.rect.html it's a simple function that just calls TypedRect::new(...)
. There are equivalent functions point2
, point3
, size2
, vec2
, etc.
from euclid.
Oh, this a global function. Didn't thought about it.
from euclid.
I'm not particularly happy about "Rect::from((0, 0, 10, 10)) // From trait" variant since it's not clear what the parameters are. Same applies to the existing rect
function to an extent.
from euclid.
Perhaps this issue should be closed as well as #321
- For the first two points of the table, the author's question has been fully resolved.
- Regarding
x()
andy()
,foo.set_width(w);
vsfoo.size.width = w;
I find your explanation satisfactory and no clarifications have followed from the author and others for 5 years :) - The only unresolved issue is with synonyms
left
,right
,top
,bottom
,width
andheight
. My suggestion - guided by the principle of "less code is better" and given the long period of time that has passed, leave it as it is. Until new considerations.
from euclid.
Related Issues (20)
- Fails to compile with --no-default-features HOT 2
- Vector missing the Sum trait HOT 3
- Support for numeric casts through `az` crate HOT 2
- Constructors: splat, one HOT 3
- Component-wise multiplication for Vector2 HOT 2
- Component-wise division for Vector2 HOT 2
- Support for bytemuck Pod and Zeroable HOT 2
- Distinguish between orientation and rotation.
- missing `AddAssign` impl for `SideOffsets2D` HOT 1
- Add tags for releases on crates.io HOT 1
- Implement more `num-traits` (e.g. checked arithmetic) HOT 2
- Poor accuracy in Vector2D::angle_from_x_axis HOT 1
- Scale `mod`, `div` by scalar HOT 3
- Unresolved Import `num_traits::Euclid` HOT 3
- Box inclusive contains HOT 7
- Point2D/Point3D missing Add<Point2D<T, U>> impl HOT 1
- Add splat function for SideOffsets2D HOT 1
- The `from_points` for `Box2D` and `Box3D` does not work quite as advertised. HOT 2
- Documentation of Transform2D does not reflect the actual calculation HOT 1
- `Rotation2D` does not implement `Debug`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from euclid.