diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2017-02-21 17:14:37 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2017-07-05 10:15:34 +0000 |
commit | 8095c33bcddefebd16b7cb08b07690caf877f600 (patch) | |
tree | 816731835b77eb798295c4324f95b23f9916ebef /examples/widgets/effects/lighting | |
parent | 827e53540c8de10f3a0b8548523ca80bf9e1c75b (diff) |
Use qRadiansToDegrees() and qDegreesToRadians() more widely
Especially in examples, where we should show off our convenience
functions, prefer calling these functions over doing arithmetic with
M_PI (or approximations thereto) and 180 (give or take simple
factors). This incidentally documents what's going on, just by the
name of the function used (and reveals at least one place where
variables were misnamed; the return from atan is in radians, *not*
degrees).
Task-number: QTBUG-58083
Change-Id: I6e5d66721cafab423378f970af525400423e971e
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'examples/widgets/effects/lighting')
-rw-r--r-- | examples/widgets/effects/lighting/lighting.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/examples/widgets/effects/lighting/lighting.cpp b/examples/widgets/effects/lighting/lighting.cpp index 68350f32b7..1ba7dd9ce7 100644 --- a/examples/widgets/effects/lighting/lighting.cpp +++ b/examples/widgets/effects/lighting/lighting.cpp @@ -49,14 +49,9 @@ ****************************************************************************/ #include "lighting.h" - #include <QtWidgets> #include <QtCore/qmath.h> -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - Lighting::Lighting(QWidget *parent): QGraphicsView(parent), angle(0.0) { setScene(&m_scene); @@ -120,7 +115,7 @@ void Lighting::setupScene() void Lighting::animate() { - angle += (M_PI / 30); + angle += qDegreesToRadians(qreal(6)); qreal xs = 200 * qSin(angle) - 40 + 25; qreal ys = 200 * qCos(angle) - 40 + 25; m_lightSource->setPos(xs, ys); |