UI-related stuff

Hello everybody. I was trying to make a simple, UI-based sketch where I am trying display ascII characters by sifting through them using a ‘slider’. But, I’ve got stuck. Any help?

  stroke (255);
  noFill ();
  rect (rectX, rectY, rectW, rectH);

  if (mousePressed) {
  
    if (linePos <= rectY) {
    
      linePos = rectY;
    
    }  else if (linePos >= lineY) {
    
        linePos = lineY;
    }    

    g = map (mouseY, height, 0, 0, 255);  
  
    linePos = g;
  
    int i = int (g);
  
    char c = char (i);
  
  text(c, 20, 75);      
  
  }

  stroke (255, 0, 0);
  line (rectX, linePos, lineX, linePos);
1 Like

Can you be more specific? Where exactly are you stuck?

Sorry. There are two things which are not running right. Firstly, the line is not staying within the confines of the ‘box’ and secondly, it’s moving in the opposite direction to the mouse.