HISE Logo Forum
    • Categories
    • Register
    • Login

    Faking A LAF Slider To Show Percent Instead Of Actual Value?!

    Scheduled Pinned Locked Moved Scripting
    13 Posts 3 Posters 386 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.
    • NatanN
      Natan
      last edited by Natan

      Hey Folks, Hope you have A Lovely Day

      As the title Says, I Painted a Slider,
      and Its value is = 362(min) & 7000(max).

      How can I fake Paint The value So it show 0% And 100% Instead of It's value?
      Thanks

      else if (obj.text == "Numeric")
          {
             g.fillAll(obj.bgColour);
             
             g.setColour(Colours.withAlpha(obj.textColour, 1.00 ));  
             g.setFont("DINPro-Bold", 16);//a[3]/2
             g.drawAlignedText(obj.value,obj.area, "centred");
             
          if (obj.hover || obj.clicked)
          {
             g.fillAll(0);
             g.setColour(0XffFFFFFF);  
             g.setFont("DINPro-Bold", 16);//a[3]/2
             g.drawAlignedText(obj.value,obj.area, "centred");
          }
            
      } // End
      
      ? d.healeyD 2 Replies Last reply Reply Quote 0
      • ?
        A Former User @Natan
        last edited by

        @natan I believe

        g.drawAlignedText(obj.valueNormalized * 100 + "%", obj.area, "centred");
        

        Might be what you're looking for :)

        NatanN 2 Replies Last reply Reply Quote 3
        • d.healeyD
          d.healey @Natan
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • NatanN
            Natan @A Former User
            last edited by

            @iamlamprey Excellent, Thanks a lot, Will it give a try Now

            1 Reply Last reply Reply Quote 0
            • NatanN
              Natan @A Former User
              last edited by

              @iamlamprey said in Faking A LAF Slider To Show Percent Instead Of Actual Value?!:

              g.drawAlignedText(obj.valueNormalized * 100 + "%", obj.area, "centred");

              Thanks Lam.
              I Guess It need to Be Rounded, It Shows A Strange Number 21.4765%

              d.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey @Natan
                last edited by

                @natan Engine.doubleToString()

                NatanN 1 Reply Last reply Reply Quote 1
                • NatanN
                  Natan @d.healey
                  last edited by

                  @d-healey said in Faking A LAF Slider To Show Percent Instead Of Actual Value?!:

                  Engine.doubleToString()

                  Thank you sir, How to Add this to The Code?

                  d.healeyD 1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Natan
                    last edited by

                    @natan Try it and see if you can work it out.

                    cf3f4b4b-0fdd-4be1-af40-91c869dcf6a7-image.png

                    1 Reply Last reply Reply Quote 0
                    • NatanN
                      Natan
                      last edited by Natan

                      @d-healey @iamlamprey Thank you Guys
                      I Found the Answer

                      g.drawAlignedText(parseInt(obj.valueNormalized * 100) + "%", obj.area, "centred");
                      

                      I Remember That I Did this Mounths Ago, Once i switched to Develop Branch,
                      This Rounds The Numbers :)

                      d.healeyD 1 Reply Last reply Reply Quote 0
                      • d.healeyD
                        d.healey @Natan
                        last edited by

                        @natan parseInt won't always work the way you expect - but in this case it's fine.

                        NatanN 1 Reply Last reply Reply Quote 1
                        • NatanN
                          Natan @d.healey
                          last edited by

                          @d-healey I Just Need The Numbers to Be In Percent, Nothing Fancy
                          Thank you Sir for Info <3 :folded_hands:

                          ? 1 Reply Last reply Reply Quote 0
                          • ?
                            A Former User @Natan
                            last edited by

                            @natan You can also use Math.round(), not sure which is the most efficient

                            NatanN 1 Reply Last reply Reply Quote 1
                            • NatanN
                              Natan @A Former User
                              last edited by

                              @iamlamprey Yeah I'll Check and See if That Works Or Not.
                              BTW This one works Just Fine
                              g.drawAlignedText(parseInt(obj.valueNormalized * 100) + "%", obj.area, "centred");

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

                              51

                              Online

                              1.7k

                              Users

                              11.7k

                              Topics

                              102.1k

                              Posts