Qt 6.x
The Qt SDK
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{
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:90
\inmodule QtCore\reentrant
Definition qpoint.h:214
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:333
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:338
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...
double generateDouble()
Generates one random qreal in the canonical range [0, 1) (that is, inclusive of zero and exclusive of...
Definition qrandom.h:58
static Q_DECL_CONST_FUNCTION QRandomGenerator * global()
\threadsafe
Definition qrandom.h:275
double bounded(double highest)
Generates one random double in the range between 0 (inclusive) and highest (exclusive).
Definition qrandom.h:72
\inmodule QtCore\reentrant
Definition qrect.h:483
constexpr qreal height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:718
constexpr qreal width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:715
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:1985
constexpr QPointF center() const noexcept
Returns the center point of the rectangle.
Definition qrect.h:685
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:92
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent