Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
/*
* SPDX-FileCopyrightText: 2019 Agata Cacko <[email protected]>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "KisSpinBoxSplineUnitConverter.h"
#include <QtMath>
#include <kis_debug.h>
double KisSpinBoxSplineUnitConverter::io2sp(int x, int min, int max)
{
int reversedRange = max - min > 0 ? 1 : -1; // tilt elevation has range (90; 0)
int rangeLen = qAbs(max - min);
double response = reversedRange * double(x - min) / rangeLen;
return response;
}
int KisSpinBoxSplineUnitConverter::sp2io(double x, int min, int max)
{
int rangeLen = max - min; // tilt elevation has range (90; 0)
int response = qRound(x*rangeLen) + min;
return response;
}