Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquicklineextruder.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
4#include <QRandomGenerator>
5
7
8/*!
9 \qmltype LineShape
10 \nativetype QQuickLineExtruder
11 \inqmlmodule QtQuick.Particles
12 \inherits ParticleExtruder
13 \brief Represents a line for affectors and emitters.
14 \ingroup qtquick-particles
15
16*/
17
18/*!
19 \qmlproperty bool QtQuick.Particles::LineShape::mirrored
20
21 By default, the line goes from (0,0) to (width, height) of the item that
22 this shape is being applied to.
23
24 If mirrored is set to true, this will be mirrored along the y axis.
25 The line will then go from (0,height) to (width, 0).
26*/
27
28QQuickLineExtruder::QQuickLineExtruder(QObject *parent) :
29 QQuickParticleExtruder(parent), m_mirrored(false)
30{
31}
32
33QPointF QQuickLineExtruder::extrude(const QRectF &r)
34{
35 qreal x,y;
36 if (!r.height()){
37 x = r.width() * QRandomGenerator::global()->generateDouble();
38 y = 0;
39 }else{
40 y = r.height() * QRandomGenerator::global()->generateDouble();
41 if (!r.width()){
42 x = 0;
43 }else{
44 x = r.width()/r.height() * y;
45 if (m_mirrored)
46 x = r.width() - x;
47 }
48 }
49 return QPointF(x,y);
50}
51
52QT_END_NAMESPACE
53
54#include "moc_qquicklineextruder_p.cpp"