GradientSlider values

This forum is for general developer support questions.

GradientSlider values

Postby mritter0 » Wed Aug 02, 2017 7:52 pm

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)
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
 
Posts: 183
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: GradientSlider values

Postby broadblues » Wed Aug 02, 2017 8:22 pm

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.
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 453
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: GradientSlider values

Postby broadblues » Wed Aug 02, 2017 8:36 pm

*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
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 453
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: GradientSlider values

Postby mritter0 » Thu Aug 03, 2017 12:01 am

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.
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
 
Posts: 183
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA


Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron