Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPerStrokeRandomSource Class Reference

#include <KisPerStrokeRandomSource.h>

+ Inheritance diagram for KisPerStrokeRandomSource:

Classes

struct  Private
 

Public Member Functions

int generate (const QString &key, int min, int max) const
 
qreal generateNormalized (const QString &key) const
 
 KisPerStrokeRandomSource ()
 
 KisPerStrokeRandomSource (const KisPerStrokeRandomSource &rhs)
 
 ~KisPerStrokeRandomSource ()
 
- Public Member Functions inherited from KisShared
bool deref ()
 
bool ref ()
 
int refCount ()
 
QAtomicInt * sharedWeakReference ()
 

Private Attributes

const QScopedPointer< Privatem_d
 

Additional Inherited Members

- Protected Member Functions inherited from KisShared
 KisShared ()
 
 ~KisShared ()
 

Detailed Description

Definition at line 17 of file KisPerStrokeRandomSource.h.

Constructor & Destructor Documentation

◆ KisPerStrokeRandomSource() [1/2]

KisPerStrokeRandomSource::KisPerStrokeRandomSource ( )

Definition at line 42 of file KisPerStrokeRandomSource.cpp.

43 : m_d(new Private(QRandomGenerator::global()->generate()))
44{
45
46}
const QScopedPointer< Private > m_d
int generate(const QString &key, int min, int max) const

◆ KisPerStrokeRandomSource() [2/2]

KisPerStrokeRandomSource::KisPerStrokeRandomSource ( const KisPerStrokeRandomSource & rhs)

Definition at line 48 of file KisPerStrokeRandomSource.cpp.

49 : KisShared(),
50 m_d(new Private(*rhs.m_d))
51{
52}

◆ ~KisPerStrokeRandomSource()

KisPerStrokeRandomSource::~KisPerStrokeRandomSource ( )

Definition at line 54 of file KisPerStrokeRandomSource.cpp.

55{
56}

Member Function Documentation

◆ generate()

int KisPerStrokeRandomSource::generate ( const QString & key,
int min,
int max ) const

Generates a random number in a range from min to max

Definition at line 76 of file KisPerStrokeRandomSource.cpp.

77{
78 return min + m_d->fetchInt(key) % (max - min);
79}
T min(T a, T b, T c)
constexpr std::enable_if< sizeof...(values)==0, size_t >::type max()

References m_d.

◆ generateNormalized()

qreal KisPerStrokeRandomSource::generateNormalized ( const QString & key) const

Generates a random number in a closed range [0; 1.0]

Definition at line 81 of file KisPerStrokeRandomSource.cpp.

82{
83 return qreal(m_d->fetchInt(key)) / m_d->generatorMax;
84}

References m_d.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisPerStrokeRandomSource::m_d
private

Definition at line 37 of file KisPerStrokeRandomSource.h.


The documentation for this class was generated from the following files: