Open bilhox opened 2 months ago
I'm not sure about the x and y variants, as
(r.w/2+N, r.h/2+M)
is shorter than (r.rel_centerx+N, r.rel_centery+M)
(where N and M are arbitrary numbers not to make the expression useless), but I like rel_center
, it makes sense.
rel_centerx
and rel_centery
are probably less readable than width/2
, and less useful compared to centerx
.
It seems to me like most uses would be related to Surface
s.
I think more concrete use cases for this feature need to be listed.
rel_centerx
andrel_centery
are probably less readable thanwidth/2
, and less useful compared tocenterx
.It seems to me like most uses would be related to
Surface
s. I think more concrete use cases for this feature need to be listed.
With the argument you gave with damus, indeed rel_centerx
and rel_centery
is not needed.
Except that, I think the person who opened the issue gave a fairly good usecase, and I personally support the feature for the same reason.
I agree that the feature is logical and should probably be implemented, but I wonder if there are more use cases than the one given:
I often find myself evaluating (rect.w / 2, rect.h / 2) to find the middle of a rect, relative to itself. This is useful when drawing a circle onto a surface for a sprite, for example.
If I understand this case correctly, one could use surface.get_rect().center
instead, right? For rects from surfaces, the position is (0,0) since only size is relevant, so rel_center
is not needed.
I personally don't see any use cases in my own project codebase, but that's probably because I use Vector2
for this stuff.
Implementation of #1242 according to MyreMylar name proposal.
While I'm bringing this feature to a potential release, what's your opinion on
rel_centerx
andrel_centery
?Closes #1242 .
Tests + documentation added.