magnify the numeric value in a knob

edited February 2018 in Library Questions

hi. How can I magnify the numeric value in a knob?

Tagged:

Answers

  • Are you, like, drawing the numbers? And you just want them drawn bigger?

    Or do you want to take the value from the knob and map it to a larger numeric range?

    perhaps you could POST SOME CODE showing us what you are attempting to do. Or maybe an image shows the effect you want.

  • edited February 2018

    hello my intention and be able to increase the size of the numbers written inside the knob ......

    /**
    * ControlP5 Knob
    *
    *
    * find a list of public methods available for the Knob Controller
    * at the bottom of this sketch.
    *
    * by Andreas Schlegel, 2012
    * www.sojamo.de/libraries/controlp5
    *
    */
    
    import controlP5.*;
    
    ControlP5 cp5;
    
    int myColorBackground = color(0,0,0);
    int knobValue = 100;
    
    Knob myKnobA;
    Knob myKnobB;
    
    void setup() {
      size(700,400);
      smooth();
      noStroke();
    
      cp5 = new ControlP5(this);
    
      myKnobA = cp5.addKnob("knob")
                   .setRange(0,255)
                   .setValue(50)
                   .setPosition(100,70)
                   .setRadius(50)
                   .setDragDirection(Knob.VERTICAL)
                   ;
    
      myKnobB = cp5.addKnob("knobValue")
                   .setRange(0,255)
                   .setValue(220)
                   .setPosition(100,210)
                   .setRadius(50)
                   .setNumberOfTickMarks(10)
                   .setTickMarkLength(4)
                   .snapToTickMarks(true)
                   .setColorForeground(color(255))
                   .setColorBackground(color(0, 160, 100))
                   .setColorActive(color(255,255,0))
                   .setDragDirection(Knob.HORIZONTAL)
                   ;
    }
    
    void draw() {
      background(myColorBackground);
      fill(knobValue);
      rect(0,height/2,width,height/2);
      fill(0,100);
      rect(80,40,140,320);
    }
    
    void knob(int theValue) {
      myColorBackground = color(theValue);
      println("a knob event. setting background to "+theValue);
    }
    
  • edited February 2018

    Not sure. It looks like the captionlabel and valuelabel are drawn here:

    https://github.com/sojamo/controlp5/blob/1f7cb649865eb8657495b5cfeddd0dbe85d70cac/src/controlP5/Knob.java#L495

    A list of all available methods on knob is at the bottom of the knob demo sketch, here:

    https://github.com/sojamo/controlp5/blob/1f7cb649865eb8657495b5cfeddd0dbe85d70cac/examples/controllers/ControlP5knob/ControlP5knob.pde#L78

    Please edit your forum post, highlight the code, and press Ctr+o to indent (properly format). This helps people read and test your code to give feedback.

  • edited February 2018

    Thanks for providing an MCVE. Here is a demo:

    PFont  f= createFont ("Georgia", 25);
    myKnobA = cp5.addKnob("knob") .setRange(0, 255) .setValue(50) .setPosition(100, 70) .setRadius(50) .setDragDirection(Knob.VERTICAL) ;
      myKnobA.getCaptionLabel().setFont(f);
      myKnobA.getValueLabel().setFont(f);
    

    Kf

  • Thanks for your help ... but I can not understand how to change the visual size of the numbers

  • Answer ✓

    @brugola You are referring to the text size, right? Introduce the extra lines above in your setup and run your example. It changes the size of the text associated with the caption of the button as well as the size of the text associated with the value of the button, which it is printed in the middle of the button.

    Kf

  • Thank you very much.... Thanks to your suggestions I succeeded ...

  • Can I ask you for another tip? How do I calibrate the sensitivity?

Sign In or Register to comment.