Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
5#include <qmath.h>
6#include <qrandom.h>
7
22 , m_fill(true)
23{
24}
25
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
41bool 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
53
54#include "moc_qquickellipseextruder_p.cpp"
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
QQuickEllipseExtruder(QObject *parent=nullptr)
\qmltype EllipseShape \instantiates QQuickEllipseExtruder \inqmlmodule QtQuick.Particles\inherits Sha...
bool contains(const QRectF &bounds, const QPointF &point) override
QPointF extrude(const QRectF &) override
\qmlproperty bool QtQuick.Particles::EllipseShape::fill If fill is true the ellipse is filled; otherw...
static Q_DECL_CONST_FUNCTION QRandomGenerator * global()
\threadsafe
Definition qrandom.h:275
\inmodule QtCore\reentrant
Definition qrect.h:484
constexpr qreal height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:732
constexpr qreal width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:729
bool contains(const QRectF &r) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrect.cpp:1993
constexpr QPointF center() const noexcept
Returns the center point of the rectangle.
Definition qrect.h:699
Combined button and popup list for selecting options.
auto qCos(T v)
Definition qmath.h:60
#define M_PI
Definition qmath.h:209
auto qSin(T v)
Definition qmath.h:54
GLboolean r
[2]
double qreal
Definition qtypes.h:187