Add "roundVector" function as convenience for rounding a QVector2D
Otherwise we constantly need to construct and deconstruct vectors.
This commit is contained in:
parent
ae01354638
commit
b8b9236ec4
1 changed files with 9 additions and 0 deletions
|
@ -38,6 +38,7 @@
|
|||
#include <netwm.h>
|
||||
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
#include <optional>
|
||||
|
||||
|
@ -196,6 +197,14 @@ KWINEFFECTS_EXPORT inline QRectF scaledRect(const QRectF &rect, qreal scale)
|
|||
return QRectF{rect.x() * scale, rect.y() * scale, rect.width() * scale, rect.height() * scale};
|
||||
}
|
||||
|
||||
/**
|
||||
* Round a vector to nearest integer.
|
||||
*/
|
||||
KWINEFFECTS_EXPORT inline QVector2D roundVector(const QVector2D &input)
|
||||
{
|
||||
return QVector2D(std::round(input.x()), std::round(input.y()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @short Base class for all KWin effects
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue