18 int channel1,
int channel2,
54 qreal y = ((1.0 - coordinate.y()) * (height() - 1 - 2 * offset)) + offset;
56 qreal triWidth = width() - 1 - 2 * offset;
57 qreal horizontalLineLength;
58 if (coordinate.y() < 0.5) {
59 horizontalLineLength = 2.0 * coordinate.y() * triWidth;
61 horizontalLineLength = 2.0 * (1.0 - coordinate.y()) * triWidth;
63 qreal horizontalLineStart = offset + 0.5 * (triWidth - horizontalLineLength);
65 qreal x = coordinate.x() * horizontalLineLength + horizontalLineStart;
76 qreal y = qBound(0.0, 1.0 - (coordinate.y() - offset)/(height() - 1 - 2 * offset), 1.0);
78 qreal triWidth = width() - 1 - 2 * offset;
79 qreal horizontalLineLength;
82 horizontalLineLength = 2.0 * y * triWidth;
84 horizontalLineLength = 2.0 * (1.0 - y) * triWidth;
87 if (horizontalLineLength > 1e-4) {
88 qreal horizontalLineStart = offset + 0.5 * (triWidth - horizontalLineLength);
89 x = qBound(0.0, (coordinate.x() - horizontalLineStart) / horizontalLineLength, 1.0);
97 const int cursorWidth = qMax(2 *
m_margin, 2);
99 maskPoly << QPoint(qFloor(0.5 * (width() - cursorWidth)), 0)
100 << QPoint(qCeil(0.5 * (width() + cursorWidth)), 0)
101 << QPoint(width(), qFloor(0.5 * height() - cursorWidth))
102 << QPoint(width(), qCeil(0.5 * height() + cursorWidth))
103 << QPoint(qCeil(0.5 * (width() + cursorWidth)), height())
104 << QPoint(qFloor(0.5 * (width() - cursorWidth)), height())
105 << QPoint(0, qCeil(0.5 * height() + cursorWidth))
106 << QPoint(0, qFloor(0.5 * height() - cursorWidth));
108 return QRegion(maskPoly);
115 const int deviceWidth = qCeil(width() * devicePixelRatioF());
116 const int deviceHeight = qCeil(height() * devicePixelRatioF());
118 QImage alphaMask(deviceWidth, deviceHeight, QImage::Format_Alpha8);
120 alphaMask.setDevicePixelRatio(devicePixelRatioF());
121 QPainter painter(&alphaMask);
122 painter.setRenderHint(QPainter::Antialiasing);
123 painter.setBrush(Qt::white);
124 painter.setPen(Qt::NoPen);
125 QPointF diamond[4] = {
128 QPointF(0.5 * width(), height() -
m_margin),
129 QPointF(width() -
m_margin, 0.5 * height())
131 painter.drawConvexPolygon(diamond, 4);
140 QBrush fill(Qt::SolidPattern);
144 painter.setPen(Qt::white);
145 fill.setColor(Qt::white);
146 painter.setBrush(fill);
147 painter.drawEllipse(cursorPoint, cursorwidth, cursorwidth);
149 painter.setPen(Qt::black);
150 painter.setBrush(fill);
151 painter.drawEllipse(cursorPoint, cursorwidth-1.0, cursorwidth-1.0);
The KisVisualColorSelectorShape class A 2d widget can represent at maximum 2 coordinates....
QPointF getCursorPosition() const
getCursorPosition
QColor getColorFromConverter(KoColor c)
getColorFromConverter
KoColor getCurrentColor()
getCurrentColor
Dimensions
The Dimensions enum Whether or not the shape is single or two dimensional.
The KisVisualColorSelector class.
void drawCursor(QPainter &painter) override
QRect getSpaceForSquare(QRect geom) override
getSpaceForSquare
~KisVisualDiamondSelectorShape() override
QImage renderAlphaMask() const override
render the alpha mask for the widget background the returned image is expected to be QImage::Format_A...
QRect getSpaceForCircle(QRect geom) override
QPointF convertShapeCoordinateToWidgetCoordinate(QPointF coordinate) const override
convertShapeCoordinateToWidgetCoordinate
KisVisualDiamondSelectorShape(KisVisualColorSelector *parent, Dimensions dimension, int channel1, int channel2, int margin=5)
void setBorderWidth(int) override
setBorderWidth set the border of the single dimensional selector.
QRegion getMaskMap() override
getPixmap
QPointF convertWidgetCoordinateToShapeCoordinate(QPointF coordinate) const override
convertWidgetCoordinateToShapeCoordinate Convert a coordinate in the widget's height/width to a shape...
QRect getSpaceForTriangle(QRect geom) override