A couple of Rectangle<float> requests


#1

I can see:

template <typename FloatType> 
Rectangle operator*= (Point<FloatType> scaleFactor) noexcept

https://github.com/julianstorer/JUCE/blob/2d134d93802feb7168625a5476e2368bc5520d2b/modules/juce_graphics/geometry/juce_Rectangle.h#L367

... but no corresponding:

...operator* ...

Also we have Rectangle::getPosition() but no corresponding ::getSize()

Any chance of these?

π


#2

Sure, good request, thanks!


#3

..oh, actually, hang on. It doesn't need this, does it?

The existing operator* takes a templated parameter, which should work just fine for a Point ??


#4

hah, indeed t'is so!  In that case, FloatType maybe should be changed to a good old T as it could be a Point<>

i.e. It's currently misleading -- easy to read too fast (like I just did), see FloatType, and assume that the overload only works for floats.

π


#5

Yes, fair point.


#6

Also we have Rectangle::getPosition() but no corresponding ::getSize()

Uhm, what should getSize() return? Point?

It certainly is intuitive to understand that the x will contain the width, and the y the height, but still.. somehow that doesn't feel right...


#7

Sure, Rectangle<T>::getSize would return a Point<T>

It isn't quite right linguistically, because a point, a vector and a size are three different beasts that just happen to each have the same storage, i.e. 2 associated numbers.

But it works well in practice I think. It's a simple construct and it's obvious what's going on.

In my own work I use Vec2 Vec3 Vec4 as generic containers for 2 3 4 floats.

I vaguely remember having to use CGPoint and CGSize on iOS...

π