From 6f4539075cdcecce2eb888f4fac566d26d5de951 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 8 Sep 2021 16:19:01 +0200 Subject: Use qDegreesToRadians() rather than hand-rolled arithmetic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doing so saves yet another approximation to pi/180 and spells out the semantics. Change-Id: Ied1bb9aa650a9535862622f891b716943de54cec Reviewed-by: Lars Knoll Reviewed-by: MÃ¥rten Nordheim --- src/svg/qsvghandler.cpp | 8 +++----- src/svg/qsvgstyle.cpp | 7 +++---- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src') 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: -- cgit v1.2.1