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")]);
    

Log in to reply
 

1
Online

315
Users

919
Topics

6.0k
Posts

Looks like your connection to Forum was lost, please wait while we try to reconnect.