6#include "colorwheelimage.h"
8#include "cielchd50values.h"
9#include "helperconstants.h"
10#include "helperconversion.h"
11#include "helpermath.h"
12#include "polarpointf.h"
13#include "rgbcolorspace.h"
17#include <qnamespace.h>
31 : m_rgbColorSpace(colorSpace)
44void ColorWheelImage::setBorder(
const qreal newBorder)
48 tempBorder = newBorder;
52 if (m_borderPhysical != tempBorder) {
53 m_borderPhysical = tempBorder;
77void ColorWheelImage::setDevicePixelRatioF(
const qreal newDevicePixelRatioF)
79 qreal tempDevicePixelRatioF;
80 if (newDevicePixelRatioF >= 1) {
81 tempDevicePixelRatioF = newDevicePixelRatioF;
83 tempDevicePixelRatioF = 1;
85 if (m_devicePixelRatioF != tempDevicePixelRatioF) {
86 m_devicePixelRatioF = tempDevicePixelRatioF;
99void ColorWheelImage::setImageSize(
const int newImageSize)
102 if (newImageSize >= 0) {
103 tempImageSize = newImageSize;
107 if (m_imageSizePhysical != tempImageSize) {
108 m_imageSizePhysical = tempImageSize;
121void ColorWheelImage::setWheelThickness(
const qreal newWheelThickness)
124 if (newWheelThickness >= 0) {
125 temp = newWheelThickness;
129 if (m_wheelThicknessPhysical != temp) {
130 m_wheelThicknessPhysical = temp;
148QImage ColorWheelImage::getImage()
151 if (!m_image.isNull()) {
158 if (m_imageSizePhysical <= 0) {
163 m_image =
QImage(
QSize(m_imageSizePhysical, m_imageSizePhysical),
168 const qreal outerCircleDiameter =
169 m_imageSizePhysical - 2 * m_borderPhysical;
172 if (outerCircleDiameter <= 0) {
177 m_image.setDevicePixelRatio(m_devicePixelRatioF);
186 PolarPointF polarCoordinates;
191 const qreal
center = (m_imageSizePhysical - 1) /
static_cast<qreal
>(2);
192 m_image =
QImage(
QSize(m_imageSizePhysical, m_imageSizePhysical),
198 cielchD50.L = CielchD50Values::neutralLightness;
199 cielchD50.C = CielchD50Values::srgbVersatileChroma;
203 const qreal minimumRadius =
204 center - m_wheelThicknessPhysical - m_borderPhysical - overlap;
205 const qreal maximumRadius =
center - m_borderPhysical + overlap;
206 for (x = 0; x < m_imageSizePhysical; ++x) {
207 for (y = 0; y < m_imageSizePhysical; ++y) {
208 polarCoordinates = PolarPointF(
QPointF(x - center, center - y));
209 if (isInRange<qreal>(minimumRadius, polarCoordinates.radius(), maximumRadius)
213 cielchD50.h = polarCoordinates.angleDegree();
214 rgbColor = m_rgbColorSpace->fromCielabD50ToQRgbOrTransparent(
215 toCmsLab(cielchD50));
216 if (qAlpha(rgbColor) != 0) {
217 m_image.setPixelColor(x, y, rgbColor);
230 const qreal circleRadius = outerCircleDiameter / 2;
231 const qreal cutOffThickness =
232 qSqrt(qPow(m_imageSizePhysical, 2) * 2) / 2
239 const qreal halfImageSize = m_imageSizePhysical /
static_cast<qreal
>(2);
240 myPainter.drawEllipse(
QPointF(halfImageSize, halfImageSize),
241 circleRadius + cutOffThickness / 2,
242 circleRadius + cutOffThickness / 2
246 const qreal innerCircleDiameter =
247 m_imageSizePhysical - 2 * (m_wheelThicknessPhysical + m_borderPhysical);
248 if (innerCircleDiameter > 0) {
253 myPainter.drawEllipse(
254 QRectF(m_wheelThicknessPhysical + m_borderPhysical,
255 m_wheelThicknessPhysical + m_borderPhysical,
257 innerCircleDiameter));
261 m_image.setDevicePixelRatio(m_devicePixelRatioF);
The namespace of this library.
QTextStream & center(QTextStream &stream)