[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [krita/krita-testing-wolthera] libs/ui/widgets: Fix selector on single-dimension hue wheel, also rot
From: Wolthera van Hovell tot Westerflier <griffinvalley () gmail ! com>
Date: 2016-08-20 11:31:41
Message-ID: E1bb4V3-0005FD-40 () code ! kde ! org
[Download RAW message or body]
Git commit b5a0d6c36c15f0e9d1d5ba821f623df151122a8a by Wolthera van Hovell tot \
Westerflier. Committed on 20/08/2016 at 11:30.
Pushed by woltherav into branch 'krita-testing-wolthera'.
Fix selector on single-dimension hue wheel, also rotate hue.
Ref T2438
M +17 -18 libs/ui/widgets/kis_visual_color_selector.cpp
http://commits.kde.org/krita/b5a0d6c36c15f0e9d1d5ba821f623df151122a8a
diff --git a/libs/ui/widgets/kis_visual_color_selector.cpp \
b/libs/ui/widgets/kis_visual_color_selector.cpp index 0b2960b..923db68 100644
--- a/libs/ui/widgets/kis_visual_color_selector.cpp
+++ b/libs/ui/widgets/kis_visual_color_selector.cpp
@@ -929,22 +929,22 @@ void KisVisualEllipticalSelectorShape::setBarWidth(int width)
QPointF KisVisualEllipticalSelectorShape::convertShapeCoordinateToWidgetCoordinate(QPointF \
coordinate) {
- qreal x = width()/2;
- qreal y = height()/2;
- QRect total(0, 0, width(), height());
- qreal a = total.width()/2;
- if (m_type!=KisVisualEllipticalSelectorShape::borderMirrored) {
- QLineF line(total.center(), total.topLeft());
- line.setAngle(coordinate.x()*360.0);
- //qreal totalLength = ( (a*b) / qSqrt( qPow( b*qCos(line.angle()),2 ) + \
qPow(a*qSin(line.angle()),2 ) ));
- line.setLength(coordinate.y()*a);
- if (getDimensions()==KisVisualColorSelectorShape::onedimensional) {
- line.setLength(a-m_barWidth);
+ qreal x;
+ qreal y;
+ qreal a = (qreal)width()*0.5;
+ QPointF center(a, a);
+ QLineF line(center, QPoint((m_barWidth*0.5),a));
+ qreal angle = coordinate.x()*360.0;
+ angle = fmod(angle+180.0,360.0);
+ line.setAngle(angle);
+ if (getDimensions()!=KisVisualColorSelectorShape::onedimensional) {
+
+ if (m_type!=KisVisualEllipticalSelectorShape::borderMirrored) {
+ line.setLength(coordinate.y()*a);
}
- x = qRound(line.p2().x());
- y = qRound(line.p2().y());
-
}
+ x = qRound(line.p2().x());
+ y = qRound(line.p2().y());
qDebug()<<QPoint(x,y);
return QPointF(x,y);
}
@@ -958,14 +958,13 @@ QPointF \
KisVisualEllipticalSelectorShape::convertWidgetCoordinateToShapeCoordina QRect \
total(0, 0, width(), height()); QLineF line(total.center(), coordinate);
qreal a = total.width()/2;
- //qreal b = qMin(total.width()/2,total.height()/2);
- //qreal totalLength = ( (a*b) / qSqrt( qPow( b*qCos(line.angle()),2 ) + \
qPow(a*qSin(line.angle()),2 ) )); +
if (m_type!=KisVisualEllipticalSelectorShape::borderMirrored){
- x = line.angle()/360.0;
+ x = fmod((line.angle()+180.0), 360.0)/360.0;
y = qBound(0.0,line.length()/a, 1.0);
} else {
- x = (line.angle()/360.0)/2;
+ x = (fmod((line.angle()+180.0), 360.0)/360.0)/2;
y = line.length()/a;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic