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
qquickellipseextruder.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
"qquickellipseextruder_p.h"
5
#
include
<
qmath
.
h
>
6
#
include
<
qrandom
.
h
>
7
8
QT_BEGIN_NAMESPACE
9
/*!
10
\qmltype EllipseShape
11
\nativetype QQuickEllipseExtruder
12
\inqmlmodule QtQuick.Particles
13
\ingroup qtquick-particles
14
\inherits Shape
15
\brief Represents an ellipse to other particle system elements.
16
17
This shape can be used by Emitter subclasses and Affector subclasses to have
18
them act upon an ellipse shaped area.
19
*/
20
QQuickEllipseExtruder::QQuickEllipseExtruder(QObject *parent) :
21
QQuickParticleExtruder(parent)
22
, m_fill(
true
)
23
{
24
}
25
26
/*!
27
\qmlproperty bool QtQuick.Particles::EllipseShape::fill
28
If fill is true the ellipse is filled; otherwise it is just a border.
29
30
Default is true.
31
*/
32
33
QPointF QQuickEllipseExtruder::extrude(
const
QRectF & r)
34
{
35
qreal theta = QRandomGenerator::global()->bounded(2 *
M_PI
);
36
qreal mag = m_fill ? QRandomGenerator::global()->generateDouble() : 1;
37
return
QPointF(r.x() + r.width()/2 + mag * (r.width()/2) * qCos(theta),
38
r.y() + r.height()/2 + mag * (r.height()/2) * qSin(theta));
39
}
40
41
bool
QQuickEllipseExtruder::contains(
const
QRectF &bounds,
const
QPointF &point)
42
{
43
if
(!bounds.contains(point))
44
return
false
;
45
46
QPointF relPoint(bounds.center() - point);
47
qreal xa = relPoint.x()/bounds.width();
48
qreal yb = relPoint.y()/bounds.height();
49
return
(xa * xa + yb * yb) < 0.25;
50
}
51
52
QT_END_NAMESPACE
53
54
#
include
"moc_qquickellipseextruder_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
M_PI
#define M_PI
Definition
qmath.h:201
qtdeclarative
src
particles
qquickellipseextruder.cpp
Generated on
for Qt by
1.18.0