Help => General => Topic started by: MarbleXeno on August 23, 2020, 09:53:10 pm
Title: How to calculate the value from the slider
Post by: MarbleXeno on August 23, 2020, 09:53:10 pm
Hello, i've created simple menu and now im working on a slider for changing the volume but i dont know how to calculate the value from the slider to change the volume of the music. I know, this is really dumb question, its simple math but for some reason i can't calculate it! I would be grateful for some pattern.
Title: Re: How to calculate the value from the slider
Post by: Laurent on August 24, 2020, 08:18:15 am
// map the slider position to [0 .. 1] auto ratio =static_cast<float>(y_cursor - y_slider_min)/(y_slider_max - y_slider_min);
// map the current position in [0 .. 1] to a volume value auto volume = ratio *(volume_max - volume_min)+ volume_min;
Title: Re: How to calculate the value from the slider
Post by: MarbleXeno on August 24, 2020, 11:11:38 am