Krita Source Code Documentation
Loading...
Searching...
No Matches
KisBezierUtils::Range Struct Reference

#include <KisBezierPatchParamSpaceUtils.h>

Public Member Functions

bool contains (qreal value) const
 
std::optional< qreal > forwardDistanceTo (const Range &rhs)
 
bool isEmpty () const
 
qreal length () const
 
qreal mid () const
 
Range squeezedRange (const Range &alphaRange) const
 
void squeezeRange (const Range &alphaRange)
 

Static Public Member Functions

static Range fromRectX (const QRectF &rc)
 
static Range fromRectY (const QRectF &rc)
 
static QRectF makeRectF (const Range &xRange, const Range &yRange)
 

Public Attributes

qreal end = 0.0
 
qreal start = 0.0
 

Detailed Description

A simple class representing a floating-point range on \R.

Definition at line 22 of file KisBezierPatchParamSpaceUtils.h.

Member Function Documentation

◆ contains()

bool KisBezierUtils::Range::contains ( qreal value) const
inline

Definition at line 39 of file KisBezierPatchParamSpaceUtils.h.

39 {
40 return value > start && value < end &&
42 qFuzzyCompare(value, end);
43 }
float value(const T *src, size_t ch)
static bool qFuzzyCompare(half p1, half p2)

References qFuzzyCompare(), start, and value().

◆ forwardDistanceTo()

std::optional< qreal > KisBezierUtils::Range::forwardDistanceTo ( const Range & rhs)
inline

Returns the "forward distance" between *this and rhs. The forward distance is undefined if the ranges overlap.

  • if the ranges overlap or touch each other with at least one point, then std::nullopt is returned
  • if *this is placed to the left of rhs, then the distance between the ranges is returned (always positive)
  • if *this is placed to the right of rhs, then the function returns the distance between the ranges taken with minus sign (always negative)

Definition at line 73 of file KisBezierPatchParamSpaceUtils.h.

73 {
74 if (rhs.start > end) {
75 return rhs.start - end;
76 } else if (start > rhs.end) {
77 return -(start - rhs.end);
78 } else {
79 return std::nullopt;
80 }
81 }

References end, and start.

◆ fromRectX()

static Range KisBezierUtils::Range::fromRectX ( const QRectF & rc)
inlinestatic

Definition at line 83 of file KisBezierPatchParamSpaceUtils.h.

83 {
84 return {rc.left(), rc.right()};
85 }

◆ fromRectY()

static Range KisBezierUtils::Range::fromRectY ( const QRectF & rc)
inlinestatic

Definition at line 87 of file KisBezierPatchParamSpaceUtils.h.

87 {
88 return {rc.top(), rc.bottom()};
89 }

◆ isEmpty()

bool KisBezierUtils::Range::isEmpty ( ) const
inline

Definition at line 27 of file KisBezierPatchParamSpaceUtils.h.

27 {
28 return qFuzzyCompare(start, end);
29 }

References qFuzzyCompare(), and start.

◆ length()

qreal KisBezierUtils::Range::length ( ) const
inline

Definition at line 31 of file KisBezierPatchParamSpaceUtils.h.

31 {
32 return end - start;
33 }

References start.

◆ makeRectF()

static QRectF KisBezierUtils::Range::makeRectF ( const Range & xRange,
const Range & yRange )
inlinestatic

Definition at line 91 of file KisBezierPatchParamSpaceUtils.h.

91 {
92 return {xRange.start, yRange.start, xRange.length(), yRange.length()};
93 }

References length(), and start.

◆ mid()

qreal KisBezierUtils::Range::mid ( ) const
inline

Definition at line 35 of file KisBezierPatchParamSpaceUtils.h.

35 {
36 return 0.5 * (end + start);
37 }

References start.

◆ squeezedRange()

Range KisBezierUtils::Range::squeezedRange ( const Range & alphaRange) const
inline

Narrow down the range by applying a relative range to it. Both ends are moved using lerp operation over the source range.

Definition at line 49 of file KisBezierPatchParamSpaceUtils.h.

49 {
51 return {lerp(start, end, alphaRange.start), lerp(start, end, alphaRange.end)};
52 }
QPointF lerp(const QPointF &p1, const QPointF &p2, qreal t)
Point lerp(const Point &pt1, const Point &pt2, qreal t)

References end, KisAlgebra2D::lerp(), lerp(), and start.

◆ squeezeRange()

void KisBezierUtils::Range::squeezeRange ( const Range & alphaRange)
inline

Definition at line 54 of file KisBezierPatchParamSpaceUtils.h.

54 {
55 *this = squeezedRange(alphaRange);
56 }
Range squeezedRange(const Range &alphaRange) const

References squeezedRange().

Member Data Documentation

◆ end

qreal KisBezierUtils::Range::end = 0.0

Definition at line 25 of file KisBezierPatchParamSpaceUtils.h.

◆ start

qreal KisBezierUtils::Range::start = 0.0

Definition at line 24 of file KisBezierPatchParamSpaceUtils.h.


The documentation for this struct was generated from the following file: