From 8095c33bcddefebd16b7cb08b07690caf877f600 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 21 Feb 2017 17:14:37 +0100 Subject: Use qRadiansToDegrees() and qDegreesToRadians() more widely MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Marc Mutz --- examples/widgets/effects/lighting/lighting.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'examples/widgets/effects') 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 #include -#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); -- cgit v1.2.3