What is the roundout() function in Rectf. What is the exact functionality of roundOut(Rect dest) function. Can any one explain this with example how this function works?
3 Answers
public void roundOut (Rect dst)
Added in API level 1
Set the dst integer Rect by rounding "out" this rectangle, choosing the floor of top and left, and the ceiling of right and bottom.
public static double floor (double d)
Added in API level 1
Returns the double conversion of the most positive (closest to positive infinity) integer value less than or equal to the argument.
Special cases:
floor(+0.0) = +0.0 floor(-0.0) = -0.0 floor(+infinity) = +infinity floor(-infinity) = -infinity floor(NaN) = NaN
public static double ceil (double d) Added in API level 1
Returns the double conversion of the most negative (closest to negative infinity) integer value greater than or equal to the argument.
Special cases:
ceil(+0.0) = +0.0 ceil(-0.0) = -0.0 ceil((anything in range (-1,0)) = -0.0 ceil(+infinity) = +infinity ceil(-infinity) = -infinity ceil(NaN) = NaN
RectF rectF = new RectF(0.0f, 0.0f, 10.5f, 20.f);
Rect rect = new Rect();
rectF.roundOut(rect);// Now rect will contains these values Rect(0, 0, 11, 20)
//What happens inside roundOut function
Math.floor(0.0f);//Results 0
Math.floor(0.0f);//Results 0
Math.ceil(10.5f);//Results 10
Math.ceil(20.f);//Results 20

- 11,309
- 2
- 38
- 48
-
shall you suggest any example code implementing above function? – Strawberry Feb 26 '14 at 13:00
-
'rectF.roundOut(new Rect(0, 0, 30, 35));' after this how the rectf will change? – Strawberry Feb 26 '14 at 13:07
rountRect
will give you a Rect
Object.
So
Rect rect = new Rect();
rectFObj.roundout(rect);
Now rect contains all values of RectF object but they are now rounded off means 1.1 becomes 1

- 14,522
- 15
- 84
- 129
One of the use which I found while searching is that roundout(Rect) is used for converting from RectF to Rect, using.
rectF.roundOut(rect);
Source - What is the best way to convert from a RectF to a Rect in Android?

- 1
- 1

- 6,692
- 4
- 39
- 74