QskGradientDirection::contais added
This commit is contained in:
parent
fff0389262
commit
ad09186229
|
@ -4,6 +4,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "QskGradientDirection.h"
|
#include "QskGradientDirection.h"
|
||||||
|
#include <qrect.h>
|
||||||
|
|
||||||
static void qskRegisterGradientDirection()
|
static void qskRegisterGradientDirection()
|
||||||
{
|
{
|
||||||
|
@ -115,6 +116,66 @@ void QskLinearDirection::setInterval( Qt::Orientation orientation, qreal from, q
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool qskIntersectsTop(
|
||||||
|
qreal vx, qreal vy, qreal m, const QRectF& rect )
|
||||||
|
{
|
||||||
|
const auto cx = vx - ( vy - rect.top() ) / m;
|
||||||
|
return cx > rect.left() && cx < rect.right();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool qskIntersectsBottom(
|
||||||
|
qreal vx, qreal vy, qreal m, const QRectF& rect )
|
||||||
|
{
|
||||||
|
const auto cx = vx - ( vy - rect.bottom() ) / m;
|
||||||
|
return cx > rect.left() && cx < rect.right();
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool qskIntersectsLeft(
|
||||||
|
qreal vx, qreal vy, qreal m, const QRectF& rect )
|
||||||
|
{
|
||||||
|
const qreal cy = vy - ( vx - rect.left() ) * m;
|
||||||
|
return ( cy > rect.top() && cy < rect.bottom() );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool qskIntersectsRight(
|
||||||
|
qreal vx, qreal vy, qreal m, const QRectF& rect )
|
||||||
|
{
|
||||||
|
const qreal cy = vy - ( vx - rect.right() ) * m;
|
||||||
|
return ( cy > rect.top() && cy < rect.bottom() );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QskLinearDirection::contains( const QRectF& rect ) const
|
||||||
|
{
|
||||||
|
if ( m_y1 == m_y2 )
|
||||||
|
{
|
||||||
|
return ( m_x1 <= rect.left() && m_x2 >= rect.right() )
|
||||||
|
|| ( m_x1 >= rect.right() && m_x2 <= rect.left() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( m_x1 == m_x2 )
|
||||||
|
{
|
||||||
|
return ( m_y1 <= rect.top() && m_y2 >= rect.bottom() )
|
||||||
|
|| ( m_y1 >= rect.bottom() && m_y2 <= rect.top() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// are the normal vectors intersecting ?
|
||||||
|
|
||||||
|
const auto m = ( m_x2 - m_x1 ) / ( m_y1 - m_y2 ); // slope of the normal vectors
|
||||||
|
|
||||||
|
const bool intersecting =
|
||||||
|
qskIntersectsLeft( m_x1, m_y1, m, rect ) ||
|
||||||
|
qskIntersectsRight( m_x1, m_y1, m, rect ) ||
|
||||||
|
qskIntersectsTop( m_x1, m_y1, m, rect ) ||
|
||||||
|
qskIntersectsBottom( m_x1, m_y1, m, rect ) ||
|
||||||
|
qskIntersectsLeft( m_x2, m_y2, m, rect ) ||
|
||||||
|
qskIntersectsRight( m_x2, m_y2, m, rect ) ||
|
||||||
|
qskIntersectsTop( m_x2, m_y2, m, rect ) ||
|
||||||
|
qskIntersectsBottom( m_x2, m_y2, m, rect );
|
||||||
|
|
||||||
|
return !intersecting;
|
||||||
|
}
|
||||||
|
|
||||||
// -- QskConicDirection
|
// -- QskConicDirection
|
||||||
|
|
||||||
void QskConicDirection::setCenter( const QPointF& center ) noexcept
|
void QskConicDirection::setCenter( const QPointF& center ) noexcept
|
||||||
|
|
|
@ -68,6 +68,8 @@ class QSK_EXPORT QskLinearDirection
|
||||||
constexpr qreal y2() const noexcept;
|
constexpr qreal y2() const noexcept;
|
||||||
void setY2( qreal ) noexcept;
|
void setY2( qreal ) noexcept;
|
||||||
|
|
||||||
|
bool contains( const QRectF& ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qreal m_x1 = 0.0;
|
qreal m_x1 = 0.0;
|
||||||
qreal m_y1 = 0.0;
|
qreal m_y1 = 0.0;
|
||||||
|
|
|
@ -78,8 +78,10 @@ void QskBoxNode::updateNode( const QRectF& rect,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
QskBoxRectangleNode supports vertical/horizontal/diagonal gradients only.
|
QskBoxRectangleNode supports vertical/horizontal and many tilted
|
||||||
If our gradient doesn't fall into this category we use a QskBoxFillNode.
|
linear gradients. If our gradient doesn't fall into this category
|
||||||
|
we use a QskBoxFillNode.
|
||||||
|
|
||||||
However the border is always done with a QskBoxRectangleNode
|
However the border is always done with a QskBoxRectangleNode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue