title: center the text inside the object and adjust the size according to the width and height of the object
body: <p>I have a rectangle object that is being displayed  with the width 50 and height 100.</p>
  
  <p>I have a text label that i want to center inside the rectangle on the sceen and adjust the size of </p>
  
  <p>the text according ( the size of text range from 0-100+) to the size of the rectangle.</p>
  
  <p>Here what i'm doing:</p>
  
  <pre><code>int rectangle_width = 50;
  
  int rectangle_height = 100;
  
  // i'm calculating the center of the rectangle 
  
  
  text_x_positon = rectangle_width/2;
  
  text_y_positon = rectangle_height/2;
  
  // calculating the size of the text label according to rectangle free space
  
  int size = (rectangle_width/rectangle_height)*10;
  
  label(text_x_positon, text_y_positon, size);
  </code></pre>
  
  <p>The problem is that sometimes the text is smaller or bigger than the rectangle, please help me to solve this problem and show me the correct way of doing it.</p>