Slider middle position formula



  • I have created a slider with a panel, the slider goes from -100 to +6 I would like the middle position of the slider to be -18, anyone know the formula I need?

    Here's my paint routine for drawing the vertical slider. I have the middle value stored as this.data.middleValue.

    var range = this.get("max") - this.get("min"); //-100 to +6
    var newVal = (this.get("height") / range) * (-this.get("min") + this.getValue());
        
    g.fillAll(this.get("bgColour"));
    g.setColour(this.get("itemColour"));
           
    g.fillRect([0, this.get("height")-newVal, this.get("width"), this.get("height")]);
    

 

2
Online

384
Users

1.2k
Topics

8.8k
Posts