10ImageMask::ImageMask(
const uint16_t width,
const uint16_t height)
16void ImageMask::setImageGeometry(
const uint16_t width,
const uint16_t height)
23bool ImageMask::isVisible(uint16_t posX, uint16_t posY)
25 return posX < m_width && posY < m_height;
28uint16_t ImageMask::width()
const
33uint16_t ImageMask::height()
const
38ImageRingMask::ImageRingMask(
const float innerRadius,
const float outerRadius,
const uint16_t width,
39 const uint16_t height) : ImageMask(width, height)
41 m_innerRadius = innerRadius;
42 m_outerRadius = outerRadius;
45void ImageRingMask::refresh()
47 long const sqDiagonal = (long) (m_width * m_width / 4 + m_height * m_height / 4);
48 m_InnerRadiusSquare = std::lround(sqDiagonal * innerRadius() * innerRadius());
49 m_OuterRadiusSquare = std::lround(sqDiagonal * outerRadius() * outerRadius());
52bool ImageRingMask::isVisible(uint16_t posX, uint16_t posY)
54 bool result = ImageMask::isVisible(posX, posY);
59 double const x = posX - m_width / 2;
60 double const y = posY - m_height / 2;
62 double const sqRadius = x * x + y * y;
64 return sqRadius >= m_InnerRadiusSquare && sqRadius < m_OuterRadiusSquare;
67float ImageRingMask::innerRadius()
const
72void ImageRingMask::setInnerRadius(
float newInnerRadius)
74 m_innerRadius = newInnerRadius;
78float ImageRingMask::outerRadius()
const
83void ImageRingMask::setOuterRadius(
float newOuterRadius)
85 m_outerRadius = newOuterRadius;
89ImageMosaicMask::ImageMosaicMask(
const uint16_t tileWidth,
const uint16_t space,
const uint16_t width,
90 const uint16_t height) : ImageMask(width, height)
92 m_tileWidth = tileWidth;
95 for (
int i = 0; i < 9; i++)
96 m_tiles.append(
QRect());
99bool ImageMosaicMask::isVisible(uint16_t posX, uint16_t posY)
101 for (
auto it = m_tiles.begin(); it != m_tiles.end(); it++)
102 if (it->contains(posX, posY))
111 const auto tileWidth = std::lround(m_width * m_tileWidth / 100);
112 const float spacex = (m_width - 3 * tileWidth - 2 * m_space) / 2;
113 const float spacey = (m_height - 3 * tileWidth - 2 * m_space) / 2;
114 for (
QRect tile : m_tiles)
118 int posy = pos++ / 3;
119 if (tile.contains(original.
x(), original.
y()))
120 return QPointF(original.
x() - posx * spacex, original.
y() - posy * spacey);
131float ImageMosaicMask::tileWidth()
const
136void ImageMosaicMask::setTileWidth(
float newTileWidth)
138 m_tileWidth = newTileWidth;
142uint16_t ImageMosaicMask::space()
const
147void ImageMosaicMask::setSpace(uint16_t newSpace)
153void ImageMosaicMask::refresh()
156 uint16_t tileWidth = std::lround(m_width * m_tileWidth / 100);
157 if (m_width > 0 && m_height > 0)
159 const auto x1 = std::lround((m_width - tileWidth) / 2);
160 const auto x2 = m_width - tileWidth - 1;
161 const auto y1 = std::lround((m_height - tileWidth) / 2);
162 const auto y2 = m_height - tileWidth - 1;
164 m_tiles.append(
QRect(0, 0, tileWidth, tileWidth));
165 m_tiles.append(
QRect(x1, 0, tileWidth, tileWidth));
166 m_tiles.append(
QRect(x2, 0, tileWidth, tileWidth));
167 m_tiles.append(
QRect(0, y1, tileWidth, tileWidth));
168 m_tiles.append(
QRect(x1, y1, tileWidth, tileWidth));
169 m_tiles.append(
QRect(x2, y1, tileWidth, tileWidth));
170 m_tiles.append(
QRect(0, y2, tileWidth, tileWidth));
171 m_tiles.append(
QRect(x1, y2, tileWidth, tileWidth));
172 m_tiles.append(
QRect(x2, y2, tileWidth, tileWidth));