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)
GradientSlider values
GradientSlider values
Workbench Explorer - A better way to browse drawers
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: GradientSlider values
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.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 not a volume knob though is it?But it is the opposite. If it were a volume control, the top is max volume, not mute.
Only because you put them backwards.Even the colors are backwards.
Seriously?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
If a value varies from 0 to range, to convert it to range to 0 just do value = range - value.
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
SliderGadget has SLIDER_Invert, looks like gradient could use that, too.
There is no need for the reverse state in the Gradient, the develeoper just needs to do some trival maths.
- broadblues
- AmigaOS Core Developer
- Posts: 600
- Joined: Sat Jun 18, 2011 2:40 am
- Location: Portsmouth, UK
- Contact:
Re: GradientSlider values
No that's wrong*EDIT*
Reverse the value: 100-((100*GradLevel)/100)
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
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.
Thanks. Getting it up and running.
Workbench Explorer - A better way to browse drawers