Krita Source Code Documentation
Loading...
Searching...
No Matches
KisScreentoneGeneratorAlignedTemplateSampler< Template > Class Template Reference

#include <KisScreentoneGeneratorTemplateSampler.h>

Public Member Functions

 KisScreentoneGeneratorAlignedTemplateSampler (const Template &the_template)
 
qreal operator() (qreal x, qreal y) const
 

Private Attributes

const Template & m_template
 

Detailed Description

template<typename Template>
class KisScreentoneGeneratorAlignedTemplateSampler< Template >

Definition at line 17 of file KisScreentoneGeneratorTemplateSampler.h.

Constructor & Destructor Documentation

◆ KisScreentoneGeneratorAlignedTemplateSampler()

template<typename Template >
KisScreentoneGeneratorAlignedTemplateSampler< Template >::KisScreentoneGeneratorAlignedTemplateSampler ( const Template & the_template)
inline

Member Function Documentation

◆ operator()()

template<typename Template >
qreal KisScreentoneGeneratorAlignedTemplateSampler< Template >::operator() ( qreal x,
qreal y ) const
inline

Definition at line 24 of file KisScreentoneGeneratorTemplateSampler.h.

25 {
26 // Get the coordinates in template space
27 QPointF p(
28 x + std::round(m_template.screenPosition().x()),
29 y + std::round(m_template.screenPosition().y())
30 );
31 // Get the coordinates in screen space
32 const QPointF screenPos = m_template.templateToScreenTransform().map(p);
33 // Get x/y indices in macrocell units or the current macrocell tile
34 // position
35 const qreal a = -std::floor(screenPos.x() / static_cast<qreal>(m_template.macrocellSize().width()));
36 const qreal b = -std::floor(screenPos.y() / static_cast<qreal>(m_template.macrocellSize().height()));
37 // Get the correspondent point in the (0, 0) macrocell tile
38 p += QPointF(a * m_template.v1().x() + b * m_template.v2().x(), a * m_template.v1().y() + b * m_template.v2().y());
39
40 const int i = static_cast<int>(std::floor(p.x())) + m_template.originOffset().x();
41 const int j = static_cast<int>(std::floor(p.y())) + m_template.originOffset().y();
42 const int macrocellPointIndex = j * m_template.templateSize().width() + i;
43 return m_template.templateData()[macrocellPointIndex];
44 }
const Params2D p

References KisScreentoneGeneratorAlignedTemplateSampler< Template >::m_template, and p.

Member Data Documentation

◆ m_template

template<typename Template >
const Template& KisScreentoneGeneratorAlignedTemplateSampler< Template >::m_template
private

Definition at line 47 of file KisScreentoneGeneratorTemplateSampler.h.


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