summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2021-09-08 16:19:01 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2021-09-09 15:58:46 +0200
commit6f4539075cdcecce2eb888f4fac566d26d5de951 (patch)
tree3f8ceb6368b8d029037fdf2823f3236bdc27923a /src
parentf890cc7b639faeacfd207966d4e484f421c0037b (diff)
downloadqtsvg-6f4539075cdcecce2eb888f4fac566d26d5de951.tar.gz
Use qDegreesToRadians() rather than hand-rolled arithmetic
Doing so saves yet another approximation to pi/180 and spells out the semantics. Change-Id: Ied1bb9aa650a9535862622f891b716943de54cec Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/svg/qsvghandler.cpp8
-rw-r--r--src/svg/qsvgstyle.cpp7
2 files changed, 6 insertions, 9 deletions
diff --git a/src/svg/qsvghandler.cpp b/src/svg/qsvghandler.cpp
index f2757bd..300979e 100644
--- a/src/svg/qsvghandler.cpp
+++ b/src/svg/qsvghandler.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt SVG module of the Qt Toolkit.
@@ -1177,13 +1177,11 @@ static QTransform parseTransformationMatrix(QStringView value)
} else if (state == SkewX) {
if (points.count() != 1)
goto error;
- const qreal deg2rad = qreal(0.017453292519943295769);
- matrix.shear(qTan(points[0]*deg2rad), 0);
+ matrix.shear(qTan(qDegreesToRadians(points[0])), 0);
} else if (state == SkewY) {
if (points.count() != 1)
goto error;
- const qreal deg2rad = qreal(0.017453292519943295769);
- matrix.shear(0, qTan(points[0]*deg2rad));
+ matrix.shear(0, qTan(qDegreesToRadians(points[0])));
}
}
error:
diff --git a/src/svg/qsvgstyle.cpp b/src/svg/qsvgstyle.cpp
index e82d89c..aa10a05 100644
--- a/src/svg/qsvgstyle.cpp
+++ b/src/svg/qsvgstyle.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt SVG module of the Qt Toolkit.
@@ -686,7 +686,6 @@ void QSvgAnimateTransform::revert(QPainter *p, QSvgExtraStates &)
void QSvgAnimateTransform::resolveMatrix(const QSvgNode *node)
{
- static const qreal deg2rad = qreal(0.017453292519943295769);
qreal totalTimeElapsed = node->document()->currentElapsed();
if (totalTimeElapsed < m_from || m_finished)
return;
@@ -786,7 +785,7 @@ void QSvgAnimateTransform::resolveMatrix(const QSvgNode *node)
qreal transXDiff = (to1-from1) * percentOfAnimation;
qreal transX = from1 + transXDiff;
m_transform = QTransform();
- m_transform.shear(qTan(transX * deg2rad), 0);
+ m_transform.shear(qTan(qDegreesToRadians(transX)), 0);
break;
}
case SkewY: {
@@ -801,7 +800,7 @@ void QSvgAnimateTransform::resolveMatrix(const QSvgNode *node)
qreal transYDiff = (to1 - from1) * percentOfAnimation;
qreal transY = from1 + transYDiff;
m_transform = QTransform();
- m_transform.shear(0, qTan(transY * deg2rad));
+ m_transform.shear(0, qTan(qDegreesToRadians(transY)));
break;
}
default: