Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qquickangledirection.cpp
Go to the documentation of this file.
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
"qquickangledirection_p.h"
5
#
include
<
QRandomGenerator
>
6
#
include
<
qmath
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
const
qreal
CONV
= 0.017453292519943295;
10
/*!
11
\qmltype AngleDirection
12
\nativetype QQuickAngleDirection
13
\inqmlmodule QtQuick.Particles
14
\ingroup qtquick-particles
15
\inherits Direction
16
\brief For specifying a direction that varies in angle.
17
18
The AngledDirection element allows both the specification of a direction by angle and magnitude,
19
as well as varying the parameters by angle or magnitude.
20
*/
21
/*!
22
\qmlproperty real QtQuick.Particles::AngleDirection::angle
23
This property specifies the base angle for the direction.
24
The angle of this direction will vary by no more than angleVariation
25
from this angle.
26
27
Angle is specified by degrees clockwise from straight right.
28
29
The default value is zero.
30
*/
31
/*!
32
\qmlproperty real QtQuick.Particles::AngleDirection::magnitude
33
This property specifies the base magnitude for the direction.
34
The magnitude of this direction will vary by no more than magnitudeVariation
35
from this magnitude.
36
37
Magnitude is specified in units of pixels per second.
38
39
The default value is zero.
40
*/
41
/*!
42
\qmlproperty real QtQuick.Particles::AngleDirection::angleVariation
43
This property specifies the maximum angle variation for the direction.
44
The angle of the direction will vary by up to angleVariation clockwise
45
and anticlockwise from the value specified in angle.
46
47
Angle is specified by degrees clockwise from straight right.
48
49
The default value is zero.
50
*/
51
/*!
52
\qmlproperty real QtQuick.Particles::AngleDirection::magnitudeVariation
53
This property specifies the base magnitude for the direction.
54
The magnitude of this direction will vary by no more than magnitudeVariation
55
from the base magnitude.
56
57
Magnitude is specified in units of pixels per second.
58
59
The default value is zero.
60
*/
61
QQuickAngleDirection::QQuickAngleDirection(QObject *parent) :
62
QQuickDirection(parent)
63
, m_angle(0)
64
, m_magnitude(0)
65
, m_angleVariation(0)
66
, m_magnitudeVariation(0)
67
{
68
69
}
70
71
QPointF QQuickAngleDirection::sample(
const
QPointF &from)
72
{
73
Q_UNUSED(from);
74
QPointF ret;
75
qreal theta = m_angle*CONV - m_angleVariation*CONV + QRandomGenerator::global()->generateDouble() * m_angleVariation*CONV * 2;
76
qreal mag = m_magnitude- m_magnitudeVariation + QRandomGenerator::global()->generateDouble() * m_magnitudeVariation * 2;
77
ret.setX(mag * qCos(theta));
78
ret.setY(mag * qSin(theta));
79
return
ret;
80
}
81
82
QT_END_NAMESPACE
83
84
#
include
"moc_qquickangledirection_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
CONV
QT_BEGIN_NAMESPACE const qreal CONV
Definition
qquickangledirection.cpp:9
qtdeclarative
src
particles
qquickangledirection.cpp
Generated on
for Qt by
1.18.0