Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSpinBoxSplineUnitConverter.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Agata Cacko <cacko.azh@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8#include <QtMath>
9#include <kis_debug.h>
10
11
12
13double KisSpinBoxSplineUnitConverter::io2sp(int x, int min, int max)
14{
15 int reversedRange = max - min > 0 ? 1 : -1; // tilt elevation has range (90; 0)
16 int rangeLen = qAbs(max - min);
17
18 double response = reversedRange * double(x - min) / rangeLen;
19 return response;
20}
21
22int KisSpinBoxSplineUnitConverter::sp2io(double x, int min, int max)
23{
24 int rangeLen = max - min; // tilt elevation has range (90; 0)
25 int response = qRound(x*rangeLen) + min;
26
27 return response;
28}
29
30
31
32
double io2sp(int x, int min, int max)
int sp2io(double x, int min, int max)