title: Android - How to rotate Rect Object?
body: <p>I have a rectangle: <code>Rect r = new Rect();</code>. I want to rotate the <code>r</code> object to 45 degrees. I checked for solutions and I found that it can be done with matrices:</p>
  
  <pre><code>Matrix m = new Matrix();
  // point is the point about which to rotate.
  m.setRotate(degrees, point.x, point.y);
  m.mapRect(r);
  </code></pre>
  
  <p>The problem is that whey I pass the <code>r</code> to <code>m.mapRect(r);</code> it complains that <code>r</code> should be from type <code>RectF</code>. I managed to do it like: </p>
  
  <pre><code>RectF r2 = new RectF(r);
  Matrix m = new Matrix();
  // point is the point about which to rotate.
  m.setRotate(degrees, point.x, point.y);
  m.mapRect(r2);
  </code></pre>
  
  <p>But the problem is that I need object from type <code>Rect</code> not <code>RectF</code> . Because I am passing the <code>r</code> object to external class which is taking a <code>Rect</code> object.</p>
  
  <p>Is there another way to rotate the rectangle <code>r</code> form type <code>Rect</code> except this method and without rotationg the whole canvas(canvas contains some other elements)?</p>
  
  <p>Thank you in advance!</p>
  
  <p>Best regards, Dimitar Georgiev</p>