Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Stick neutral point of the tilt-direction to the 3 o'clock position

Dmitry Kazakovd4dcad9b3d6e
diff --git a/libs/image/brushengine/kis_paint_information.cc b/libs/image/brushengine/kis_paint_information.cc
index bac05ef178..d5f8599fde 100644
--- a/libs/image/brushengine/kis_paint_information.cc
+++ b/libs/image/brushengine/kis_paint_information.cc
@@ -652,8 +652,23 @@ qreal KisPaintInformation::tiltDirection(const KisPaintInformation& info, bool n
{
qreal xTilt = info.xTilt();
qreal yTilt = info.yTilt();
+
// radians -PI, PI
- qreal tiltDirection = atan2(-xTilt, yTilt);
+ qreal tiltDirection = 0.0;
+
+ if (qFuzzyIsNull(xTilt) && qFuzzyIsNull(yTilt)) {
+ /**
+ * When the stylus is in fully vertical position, stick it
+ * to a "neutral position", which is a 3 o'clock tilt of the stylus
+ * as defined in the Krita documentation.
+ *
+ * The normal 0 deg position as returned from Qt is at 6 o'clock
+ * tilt of the stylus
+ */
+ tiltDirection = - KisAlgebra2D::signPZ(xTilt) * KisAlgebra2D::signPZ(yTilt) * M_PI_2;
+ } else {
+ tiltDirection = atan2(-xTilt, yTilt);
+ }
if (!qFuzzyIsNull(info.d->tiltDirectionOffset)) {
tiltDirection += kisDegreesToRadians(info.d->tiltDirectionOffset);