[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra/calligra/2.9] krita/libbrush: Replace duplicated code for angle arithmetic
From:       Michael Abrahams <miabraha () gmail ! com>
Date:       2015-07-28 19:39:09
Message-ID: E1ZKAiT-0007l5-RO () scm ! kde ! org
[Download RAW message or body]

Git commit c68e00627fe51fdb44f1a56718bfb46856c248f9 by Michael Abrahams.
Committed on 28/07/2015 at 19:38.
Pushed by abrahams into branch 'calligra/2.9'.

Replace duplicated code for angle arithmetic

Summary: This uses an existing angle arithmetic function.

Reviewers: dkazakov, rempt

Differential Revision: https://phabricator.kde.org/D196

M  +5    -31   krita/libbrush/kis_brush.cpp

http://commits.kde.org/calligra/c68e00627fe51fdb44f1a56718bfb46856c248f9

diff --git a/krita/libbrush/kis_brush.cpp b/krita/libbrush/kis_brush.cpp
index e81d054..ea389ee 100644
--- a/krita/libbrush/kis_brush.cpp
+++ b/krita/libbrush/kis_brush.cpp
@@ -342,11 +342,7 @@ qint32 KisBrush::maskWidth(double scale, double angle, qreal subPixelX, qreal su
 {
     Q_UNUSED(info);
 
-    angle += d->angle;
-
-    // Make sure the angle stay in [0;2*M_PI]
-    if (angle < 0) angle += 2 * M_PI;
-    if (angle > 2 * M_PI) angle -= 2 * M_PI;
+    angle = normalizeAngle(angle + d->angle);
     scale *= d->scale;
 
     return KisQImagePyramid::imageSize(QSize(width(), height()),
@@ -358,11 +354,7 @@ qint32 KisBrush::maskHeight(double scale, double angle, qreal subPixelX, qreal s
 {
     Q_UNUSED(info);
 
-    angle += d->angle;
-
-    // Make sure the angle stay in [0;2*M_PI]
-    if (angle < 0) angle += 2 * M_PI;
-    if (angle > 2 * M_PI) angle -= 2 * M_PI;
+    angle = normalizeAngle(angle + d->angle);
     scale *= d->scale;
 
     return KisQImagePyramid::imageSize(QSize(width(), height()),
@@ -372,17 +364,7 @@ qint32 KisBrush::maskHeight(double scale, double angle, qreal subPixelX, qreal s
 
 double KisBrush::maskAngle(double angle) const
 {
-    angle += d->angle;
-
-    // Make sure the angle stay in [0;2*M_PI]
-    if (angle < 0)      {
-        angle += 2 * M_PI;
-    }
-    if (angle > 2 * M_PI) {
-        angle -= 2 * M_PI;
-    }
-
-    return angle;
+    return normalizeAngle(angle + d->angle);
 }
 
 quint32 KisBrush::brushIndex(const KisPaintInformation& info) const
@@ -463,11 +445,7 @@ void KisBrush::generateMaskAndApplyMaskOrCreateDab(KisFixedPaintDeviceSP dst,
     Q_UNUSED(info_);
     Q_UNUSED(softnessFactor);
 
-    angle += d->angle;
-
-    // Make sure the angle stay in [0;2*M_PI]
-    if (angle < 0) angle += 2 * M_PI;
-    if (angle > 2 * M_PI) angle -= 2 * M_PI;
+    angle   = normalizeAngle(angle + d->angle);
     scaleX *= d->scale;
     scaleY *= d->scale;
 
@@ -558,11 +536,7 @@ KisFixedPaintDeviceSP KisBrush::paintDevice(const KoColorSpace * colorSpace,
 {
     Q_ASSERT(valid());
     Q_UNUSED(info);
-    angle += d->angle;
-
-    // Make sure the angle stay in [0;2*M_PI]
-    if (angle < 0) angle += 2 * M_PI;
-    if (angle > 2 * M_PI) angle -= 2 * M_PI;
+    angle  = normalizeAngle(angle + d->angle);
     scale *= d->scale;
 
     prepareBrushPyramid();
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic