Page 1 of 1

GradientSlider values

Posted: Wed Aug 02, 2017 6:52 pm
by mritter0
I just added a vertical gradient slider. To me the values seems backwards: the bottom should be 0, the top should be 100. But it is the opposite. If it were a volume control, the top is max volume, not mute. Even the colors are backwards.

Is there a formula, or function, to reverse the values?
If at top 0->100.
If at 75% 25->75
If at 50% 50->50
If at 25% 75->25
If at bottom 100->0

SliderGadget has SLIDER_Invert, looks like gradient could use that, too.


*EDIT*
Reverse the value: 100-((100*GradLevel)/100)

Re: GradientSlider values

Posted: Wed Aug 02, 2017 7:22 pm
by broadblues
I just added a vertical gradient slider. To me the values seems backwards: the bottom should be 0, the top should be 100.
It's a gradient slider, the actual value is arbitrary, when used in cnonjuntion withy a colour wheel, you allow the colour wheel to setup the values, and the brrightest colour is at the top.
But it is the opposite. If it were a volume control, the top is max volume, not mute.
It's not a volume knob though is it?
Even the colors are backwards.
Only because you put them backwards.
Is there a formula, or function, to reverse the values?
If at top 0->100.
If at 75% 25->75
If at 50% 50->50
If at 25% 75->25
If at bottom 100->0
Seriously?

If a value varies from 0 to range, to convert it to range to 0 just do value = range - value.

SliderGadget has SLIDER_Invert, looks like gradient could use that, too.
Whilst it could be added the gradient is picking arbitrary values that represent a colour, whereas the silder gadget is picking the actual values, and, more to the point, can display those values

There is no need for the reverse state in the Gradient, the develeoper just needs to do some trival maths.

Re: GradientSlider values

Posted: Wed Aug 02, 2017 7:36 pm
by broadblues
*EDIT*
Reverse the value: 100-((100*GradLevel)/100)
No that's wrong

If you want avalue from 0 to 100 just set GRAD_MaxVal to 100

The the inverted result is 100 - GradLevel

If for some reason you need maximum resolution (as I do in my SketchBlock colour window which generates floating point colour (albeit with only16 bits of precision against the max of 24)

Then
Non iverted
((float)GradLevel * 100.0) / (float)0xFFFF

Inverted
(100.0 * (float)(0xFFFF - GradLevel) ) / (float)0xFFFF

Be carefult of the brackets

Re: GradientSlider values

Posted: Wed Aug 02, 2017 11:01 pm
by mritter0
Note to self: don't try to program at work when not enough time; you word your questions poorly.

Thanks. Getting it up and running.