| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include "qquickparticleextruder_p.h" |
| 5 | #include <QRandomGenerator> |
| 6 | |
| 7 | QT_BEGIN_NAMESPACE |
| 8 | |
| 9 | /*! |
| 10 | \qmltype ParticleExtruder |
| 11 | \nativetype QQuickParticleExtruder |
| 12 | \inqmlmodule QtQuick.Particles |
| 13 | \brief For specifying an area for affectors and emitters. |
| 14 | \ingroup qtquick-particles |
| 15 | |
| 16 | The base class is just a rectangle. |
| 17 | */ |
| 18 | |
| 19 | QQuickParticleExtruder::QQuickParticleExtruder(QObject *parent) : |
| 20 | QObject(parent) |
| 21 | { |
| 22 | } |
| 23 | |
| 24 | QPointF QQuickParticleExtruder::extrude(const QRectF &rect) |
| 25 | { |
| 26 | return QPointF(QRandomGenerator::global()->generateDouble() * rect.width() + rect.x(), |
| 27 | QRandomGenerator::global()->generateDouble() * rect.height() + rect.y()); |
| 28 | } |
| 29 | |
| 30 | bool QQuickParticleExtruder::contains(const QRectF &bounds, const QPointF &point) |
| 31 | { |
| 32 | return bounds.contains(p: point); |
| 33 | } |
| 34 | |
| 35 | QT_END_NAMESPACE |
| 36 | |
| 37 | #include "moc_qquickparticleextruder_p.cpp" |
| 38 |
