Pl Explain math in Dial qml example
In Qt SDK 1.1 (Dial control example) Dial.qml the angle of needle is represented by
angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133)
where did the -130,130,133 value come from? Why is a factor of 2.6 used?
Aesthetics probably. Angles between -130 and +133 are shown. This whole thing results in root.value being a number between 0 and (133 + 130)/2.6, which is 263/2.6 ~= 100.
So given that information, it is all about scaling a 0-100 value to range that looks nice.
Seems to make sense now. The 'dial control' code shows the x position has been multiplied by a factor of 100, so to offset that dial code has been scaled down by roughly 100 but the dial has value up 0 to 120 - so they are off by 20 degree ? To offset slider which is 34 px in width, 30 px has been subtracted from slider container width. Why would they complicate the code unnecessarily is beyond me.
I do not know the example. I just reasoned backwards from the chunk of code you posted.