diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2017-06-12 15:28:13 -0700 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-08-23 04:47:59 +0000 |
commit | 2b7b24a0e039a18db8ab23475fbab44718f758a2 (patch) | |
tree | 0cfb916871a7e48d843dcd371d723a7d6083f2a6 /src/particles/qquickrectangleextruder.cpp | |
parent | 46ed14da325c6c0382c0bc54cacc347d2d7f2b0a (diff) |
Use QRandomGenerator instead of q?rand
Change-Id: Icd0e0d4b27cb4e5eb892fffd14b5285d43f4afbf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/particles/qquickrectangleextruder.cpp')
-rw-r--r-- | src/particles/qquickrectangleextruder.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/particles/qquickrectangleextruder.cpp b/src/particles/qquickrectangleextruder.cpp index cb166f1d50..6474f61630 100644 --- a/src/particles/qquickrectangleextruder.cpp +++ b/src/particles/qquickrectangleextruder.cpp @@ -38,7 +38,7 @@ ****************************************************************************/ #include "qquickrectangleextruder_p.h" -#include <stdlib.h> +#include <QRandomGenerator> QT_BEGIN_NAMESPACE @@ -60,21 +60,21 @@ QQuickRectangleExtruder::QQuickRectangleExtruder(QObject *parent) : QPointF QQuickRectangleExtruder::extrude(const QRectF &rect) { if (m_fill) - return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(), - ((qreal)rand() / RAND_MAX) * rect.height() + rect.y()); - int side = rand() % 4; + return QPointF(QRandomGenerator::getReal() * rect.width() + rect.x(), + QRandomGenerator::getReal() * rect.height() + rect.y()); + int side = QRandomGenerator::bounded(4); switch (side){//TODO: Doesn't this overlap the corners? case 0: return QPointF(rect.x(), - ((qreal)rand() / RAND_MAX) * rect.height() + rect.y()); + QRandomGenerator::getReal() * rect.height() + rect.y()); case 1: return QPointF(rect.width() + rect.x(), - ((qreal)rand() / RAND_MAX) * rect.height() + rect.y()); + QRandomGenerator::getReal() * rect.height() + rect.y()); case 2: - return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(), + return QPointF(QRandomGenerator::getReal() * rect.width() + rect.x(), rect.y()); default: - return QPointF(((qreal)rand() / RAND_MAX) * rect.width() + rect.x(), + return QPointF(QRandomGenerator::getReal() * rect.width() + rect.x(), rect.height() + rect.y()); } } |