HISE Logo Forum
    • Categories
    • Register
    • Login

    Slider middle position formula

    Scheduled Pinned Locked Moved Scripting
    1 Posts 1 Posters 396 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • d.healeyD
      d.healey
      last edited by

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

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      1 Reply Last reply Reply Quote 0
      • First post
        Last post

      33

      Online

      1.8k

      Users

      12.0k

      Topics

      104.1k

      Posts