Knob positions vs. slider values
pointForValue() function you can get a readout of what would be a knob’s position for a particular value.
valueForPoint() works the other way round: you give it a (hypothetical) position of a knob, and it will return the value this would generate.
These functions don’t change anything to the slider or knobs; they just return the numbers the slider uses internally. They are also the exact same functions as on a standard SliderComponent.
We have a default range slider:
slider = new RangeSliderComponent
With its default
min value of
0, and default
1, the position for value
0.5 will be at
# What would be the location of a knob # for a value of 0.5? print slider.pointForValue 0.5 » 150
This, of course, is what would be the
x position of a knob inside its parent (the slider itself) and not the position of the knob on the screen. (For a vertical slider you will get a
valueForPoint() function does exactly the reverse.
# What would be the value for a knob # that’s halfway (at 150 points)? print slider.valueForPoint 150 » 0.5