6#ifndef QSK_GRDIENT_DIRECTION_H
7#define QSK_GRDIENT_DIRECTION_H
19 Q_PROPERTY( qreal x1 READ x1 WRITE setX1 )
20 Q_PROPERTY( qreal y1 READ y1 WRITE setY1 )
21 Q_PROPERTY( qreal x2 READ x2 WRITE setX2 )
22 Q_PROPERTY( qreal y2 READ y2 WRITE setY2 )
33 void setVector(
const QLineF& )
noexcept;
34 void setVector(
const QPointF&,
const QPointF& )
noexcept;
35 void setVector( qreal x1, qreal y1, qreal x2, qreal y2 )
noexcept;
37 constexpr QLineF vector()
const noexcept;
39 void setStart(
const QPointF& )
noexcept;
40 void setStart( qreal x, qreal y )
noexcept;
42 void setStop(
const QPointF& )
noexcept;
43 void setStop( qreal x, qreal y )
noexcept;
45 void setInterval( Qt::Orientation, qreal, qreal );
47 void setOrientation( Qt::Orientation )
noexcept;
48 constexpr bool isOriented( Qt::Orientation )
const noexcept;
50 constexpr bool isHorizontal()
const noexcept;
51 constexpr bool isVertical()
const noexcept;
52 constexpr bool isTilted()
const noexcept;
54 constexpr QPointF start()
const noexcept;
55 constexpr QPointF stop()
const noexcept;
57 constexpr qreal x1()
const noexcept;
58 void setX1( qreal )
noexcept;
60 constexpr qreal y1()
const noexcept;
61 void setY1( qreal )
noexcept;
63 constexpr qreal x2()
const noexcept;
64 void setX2( qreal )
noexcept;
66 constexpr qreal y2()
const noexcept;
67 void setY2( qreal )
noexcept;
69 qreal dx()
const noexcept;
70 qreal dy()
const noexcept;
80 qreal valueAt(
const QPointF& )
const;
81 qreal valueAt( qreal x, qreal y )
const;
83 bool contains(
const QRectF& )
const;
86 void precalculate()
const noexcept;
93 mutable qreal m_dx = 0.0;
94 mutable qreal m_dy = 0.0;
95 mutable qreal m_dot = -1.0;
102 Q_PROPERTY( qreal x READ x WRITE setX )
103 Q_PROPERTY( qreal y READ y WRITE setY )
104 Q_PROPERTY( qreal startAngle READ startAngle WRITE setStartAngle )
105 Q_PROPERTY( qreal spanAngle READ spanAngle WRITE setSpanAngle )
106 Q_PROPERTY( qreal aspectRatio READ aspectRatio WRITE setAspectRatio )
112 constexpr QskConicDirection( qreal x, qreal y, qreal startAngle = 0.0 )
noexcept;
114 qreal startAngle, qreal spanAngle, qreal aspectRatio = 0.0 )
noexcept;
118 qreal startAngle, qreal spanAngle, qreal aspectRatio = 0.0 )
noexcept;
120 constexpr QPointF center()
const noexcept;
121 void setCenter(
const QPointF& center)
noexcept;
122 void setCenter(qreal x, qreal y)
noexcept;
124 void setX( qreal )
noexcept;
125 constexpr qreal x()
const noexcept;
127 void setY( qreal )
noexcept;
128 constexpr qreal y()
const noexcept;
130 constexpr qreal startAngle()
const noexcept;
131 void setStartAngle( qreal )
noexcept;
133 constexpr qreal spanAngle()
const noexcept;
134 void setSpanAngle( qreal )
noexcept;
136 constexpr qreal aspectRatio()
const noexcept;
137 void setAspectRatio( qreal )
noexcept;
142 qreal m_startAngle = 0.0;
143 qreal m_spanAngle = 360.0;
144 qreal m_aspectRatio = 0.0;
151 Q_PROPERTY( qreal x READ x WRITE setX )
152 Q_PROPERTY( qreal y READ y WRITE setY )
153 Q_PROPERTY( qreal radiusX READ radiusX WRITE setRadiusX )
154 Q_PROPERTY( qreal radiusY READ radiusY WRITE setRadiusY )
161 constexpr QskRadialDirection( qreal cx, qreal cy, qreal radiusX, qreal radiusY )
noexcept;
163 constexpr QPointF center()
const noexcept;
164 void setCenter(
const QPointF& )
noexcept;
165 void setCenter(qreal x, qreal y)
noexcept;
167 void setX( qreal )
noexcept;
168 constexpr qreal x()
const noexcept;
170 void setY( qreal )
noexcept;
171 constexpr qreal y()
const noexcept;
173 constexpr qreal radiusX()
const noexcept;
174 void setRadiusX( qreal )
noexcept;
176 constexpr qreal radiusY()
const noexcept;
177 void setRadiusY( qreal )
noexcept;
179 void setRadius( qreal )
noexcept;
180 void setRadius( qreal, qreal )
noexcept;
185 qreal m_radiusX = 0.5;
186 qreal m_radiusY = 0.5;
189inline constexpr QskLinearDirection::QskLinearDirection(
190 Qt::Orientation orientation ) noexcept
191 : m_x2( ( orientation == Qt::Vertical ) ? 0.0 : 1.0 )
192 , m_y2( ( orientation == Qt::Vertical ) ? 1.0 : 0.0 )
196inline constexpr QskLinearDirection::QskLinearDirection(
const QLineF& vector ) noexcept
201inline constexpr QskLinearDirection::QskLinearDirection(
202 const QPointF& start,
const QPointF& stop ) noexcept
207inline constexpr QskLinearDirection::QskLinearDirection(
208 qreal x1, qreal y1, qreal x2, qreal y2 ) noexcept
216inline constexpr qreal QskLinearDirection::x1() const noexcept
221inline constexpr qreal QskLinearDirection::y1() const noexcept
226inline constexpr qreal QskLinearDirection::x2() const noexcept
231inline constexpr qreal QskLinearDirection::y2() const noexcept
236inline qreal QskLinearDirection::dx() const noexcept
244inline qreal QskLinearDirection::dy() const noexcept
252inline constexpr QLineF QskLinearDirection::vector() const noexcept
254 return QLineF( m_x1, m_y1, m_x2, m_y2 );
257inline constexpr QPointF QskLinearDirection::start() const noexcept
259 return QPointF( m_x1, m_y1 );
262inline constexpr QPointF QskLinearDirection::stop() const noexcept
264 return QPointF( m_x2, m_y2 );
267inline constexpr bool QskLinearDirection::isOriented(
268 Qt::Orientation orientation )
const noexcept
270 return ( orientation == Qt::Horizontal ) ? isHorizontal() : isVertical();
273inline constexpr bool QskLinearDirection::isHorizontal() const noexcept
275 return !isVertical() && ( m_y1 == m_y2 );
278inline constexpr bool QskLinearDirection::isVertical() const noexcept
283inline constexpr bool QskLinearDirection::isTilted() const noexcept
285 return ( m_x1 != m_x2 ) && ( m_y1 != m_y2 );
288inline qreal QskLinearDirection::valueAt(
const QPointF& pos )
const
290 return valueAt( pos.x(), pos.y() );
293inline qreal QskLinearDirection::valueAt( qreal x, qreal y )
const
298 return ( ( x - m_x1 ) * m_dx + ( y - m_y1 ) * m_dy ) / m_dot;
301inline constexpr QskConicDirection::QskConicDirection(
302 qreal x, qreal y, qreal startAngle ) noexcept
307inline constexpr QskConicDirection::QskConicDirection( qreal x, qreal y,
308 qreal startAngle, qreal spanAngle, qreal aspectRatio ) noexcept
311 , m_startAngle( startAngle )
312 , m_spanAngle( spanAngle )
313 , m_aspectRatio( aspectRatio )
317inline constexpr QskConicDirection::QskConicDirection(
318 const QPointF& pos, qreal startAngle ) noexcept
323inline constexpr QskConicDirection::QskConicDirection(
const QPointF& pos,
324 qreal startAngle, qreal spanAngle, qreal apectRatio ) noexcept
329inline constexpr QPointF QskConicDirection::center() const noexcept
331 return QPointF( m_x, m_y );
334inline constexpr qreal QskConicDirection::startAngle() const noexcept
339inline constexpr qreal QskConicDirection::spanAngle() const noexcept
344inline constexpr qreal QskConicDirection::x() const noexcept
349inline constexpr qreal QskConicDirection::y() const noexcept
354inline constexpr qreal QskConicDirection::aspectRatio() const noexcept
356 return m_aspectRatio;
359inline constexpr QskRadialDirection::QskRadialDirection(
360 qreal x, qreal y, qreal radius ) noexcept
363 , m_radiusX( radius )
364 , m_radiusY( radius )
368inline constexpr QskRadialDirection::QskRadialDirection(
369 qreal x, qreal y, qreal radiusX, qreal radiusY ) noexcept
372 , m_radiusX( radiusX )
373 , m_radiusY( radiusY )
377inline constexpr QskRadialDirection::QskRadialDirection(
378 const QPointF& center, qreal radius ) noexcept
383inline constexpr QPointF QskRadialDirection::center() const noexcept
385 return QPointF( m_x, m_y );
388inline constexpr qreal QskRadialDirection::x() const noexcept
393inline constexpr qreal QskRadialDirection::y() const noexcept
398inline constexpr qreal QskRadialDirection::radiusX() const noexcept
403inline constexpr qreal QskRadialDirection::radiusY() const noexcept