Forum

    • Register
    • Login
    • Search
    • Categories

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

    Scripting Forum
    3
    13
    45
    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.
    • Natan
      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
      
      iamlamprey d.healey 2 Replies Last reply Reply Quote 0
      • iamlamprey
        iamlamprey @Natan last edited by

        @natan I believe

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

        Might be what you're looking for 🙂

        Music - Instruments

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

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • Natan
            Natan @iamlamprey last edited by

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

            1 Reply Last reply Reply Quote 0
            • Natan
              Natan @iamlamprey 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.healey 1 Reply Last reply Reply Quote 0
              • d.healey
                d.healey @Natan last edited by

                @natan Engine.doubleToString()

                Natan 1 Reply Last reply Reply Quote 1
                • Natan
                  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.healey 1 Reply Last reply Reply Quote 0
                  • d.healey
                    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
                    • Natan
                      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.healey 1 Reply Last reply Reply Quote 0
                      • d.healey
                        d.healey @Natan last edited by

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

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

                          @d-healey I Just Need The Numbers to Be In Percent, Nothing Fancy
                          Thank you Sir for Info ❤ 🙏

                          iamlamprey 1 Reply Last reply Reply Quote 0
                          • iamlamprey
                            iamlamprey @Natan last edited by

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

                            Music - Instruments

                            Natan 1 Reply Last reply Reply Quote 1
                            • Natan
                              Natan @iamlamprey 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

                              7
                              Online

                              740
                              Users

                              5.4k
                              Topics

                              50.4k
                              Posts