Browse Source

Add Rectangle::containsAfterScaling method

Signed-off-by: falkTX <falktx@falktx.com>
pull/309/head
falkTX 3 years ago
parent
commit
1b7e47742c
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 11 additions and 0 deletions
  1. +5
    -0
      dgl/Geometry.hpp
  2. +6
    -0
      dgl/src/Geometry.cpp

+ 5
- 0
dgl/Geometry.hpp View File

@@ -753,6 +753,11 @@ public:
*/
bool contains(const Point<T>& pos) const noexcept;

/**
Check if this rectangle contains the point @a pos affected by a custom scale.
*/
bool containsAfterScaling(const Point<T>& pos, double scaling) const noexcept;

/**
Check if this rectangle contains the point @a pos of another type.
*/


+ 6
- 0
dgl/src/Geometry.cpp View File

@@ -925,6 +925,12 @@ bool Rectangle<uint>::contains(const Point<double>& p) const noexcept
return (p.x >= pos.x && p.y >= pos.y && p.x <= pos.x+size.fWidth && p.y <= pos.y+size.fHeight);
}

template<typename T>
bool Rectangle<T>::containsAfterScaling(const Point<T>& p, const double scaling) const noexcept
{
return (p.x >= pos.x && p.y >= pos.y && p.x/scaling <= pos.x+size.fWidth && p.y/scaling <= pos.y+size.fHeight);
}

template<typename T>
bool Rectangle<T>::containsX(const T& x) const noexcept
{


Loading…
Cancel
Save