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 "qquickpointdirection_p.h" |
5 | #include <QRandomGenerator> |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | /*! |
10 | \qmltype PointDirection |
11 | \instantiates QQuickPointDirection |
12 | \inqmlmodule QtQuick.Particles |
13 | \ingroup qtquick-particles |
14 | \inherits Direction |
15 | \brief For specifying a direction that varies in x and y components. |
16 | |
17 | The PointDirection element allows both the specification of a direction by x and y components, |
18 | as well as varying the parameters by x or y component. |
19 | */ |
20 | /*! |
21 | \qmlproperty real QtQuick.Particles::PointDirection::x |
22 | */ |
23 | /*! |
24 | \qmlproperty real QtQuick.Particles::PointDirection::y |
25 | */ |
26 | /*! |
27 | \qmlproperty real QtQuick.Particles::PointDirection::xVariation |
28 | */ |
29 | /*! |
30 | \qmlproperty real QtQuick.Particles::PointDirection::yVariation |
31 | */ |
32 | |
33 | QQuickPointDirection::QQuickPointDirection(QObject *parent) : |
34 | QQuickDirection(parent) |
35 | , m_x(0) |
36 | , m_y(0) |
37 | , m_xVariation(0) |
38 | , m_yVariation(0) |
39 | { |
40 | } |
41 | |
42 | QPointF QQuickPointDirection::sample(const QPointF &) |
43 | { |
44 | QPointF ret; |
45 | ret.setX(m_x - m_xVariation + QRandomGenerator::global()->generateDouble() * m_xVariation * 2); |
46 | ret.setY(m_y - m_yVariation + QRandomGenerator::global()->generateDouble() * m_yVariation * 2); |
47 | return ret; |
48 | } |
49 | |
50 | QT_END_NAMESPACE |
51 | |
52 | #include "moc_qquickpointdirection_p.cpp" |
53 |