Giter Site home page Giter Site logo

Rect usability improvements about euclid HOT 6 CLOSED

RazrFalcon avatar RazrFalcon commented on May 19, 2024 4
Rect usability improvements

from euclid.

Comments (6)

nical avatar nical commented on May 19, 2024 1

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.

RazrFalcon avatar RazrFalcon commented on May 19, 2024

you can write let r = rect(x, y, w, h);

How it works?

Should I make a pull request?

from euclid.

nical avatar nical commented on May 19, 2024

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.

RazrFalcon avatar RazrFalcon commented on May 19, 2024

Oh, this a global function. Didn't thought about it.

from euclid.

kvark avatar kvark commented on May 19, 2024

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.

ArtHome12 avatar ArtHome12 commented on May 19, 2024

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() and y(), foo.set_width(w); vs foo.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 and height. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.