summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2017-02-22 19:01:32 (GMT)
committerEdward Welbourne <edward.welbourne@qt.io>2017-06-21 08:40:39 (GMT)
commitf200e303829106db6e3ff32e0c492d2677531c33 (patch)
treeaa6d92565cea594b573b931f30a8a0b805d42b7b
parent0ac21330b6cf5f95d733f16ff16614879000b588 (diff)
downloadqtscript-f200e303829106db6e3ff32e0c492d2677531c33.tar.gz
Use qRadiansToDegrees() instead of hand-coding an equivalent
The homegrown approximation to pi's value caught my attention. Task-number: QTBUG-58083 Change-Id: I2bf0432f4c71c20131ef48cdd8341cdb9bc098bc Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
-rw-r--r--examples/script/context2d/context2d.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/examples/script/context2d/context2d.cpp b/examples/script/context2d/context2d.cpp
index 70ef104..ddb40b7 100644
--- a/examples/script/context2d/context2d.cpp
+++ b/examples/script/context2d/context2d.cpp
@@ -41,11 +41,7 @@
#include "context2d.h"
#include <QVariant>
-
-#include <math.h>
-static const double Q_PI = 3.14159265358979323846; // pi
-
-#define DEGREES(t) ((t) * 180.0 / Q_PI)
+#include <qmath.h>
#define qClamp(val, min, max) qMin(qMax(val, min), max)
static QList<qreal> parseNumbersList(QString::const_iterator &itr)
@@ -224,7 +220,7 @@ void Context2D::scale(qreal x, qreal y)
void Context2D::rotate(qreal angle)
{
- m_state.matrix.rotate(DEGREES(angle));
+ m_state.matrix.rotate(qRadiansToDegrees(angle));
m_state.flags |= DirtyTransformationMatrix;
}
@@ -573,8 +569,8 @@ void Context2D::arc(qreal xc, qreal yc, qreal radius,
anticlockwise = !anticlockwise;
//end hack
- float sa = DEGREES(sar);
- float ea = DEGREES(ear);
+ float sa = qRadiansToDegrees(sar);
+ float ea = qRadiansToDegrees(ear);
double span = 0;