Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Rect to RectF

Whats the best way to convert a Rect variable to a RectF one? I am unable to cast it.

RectF rect = (RectF) currentRect; //produces an error
like image 351
industrychanger Avatar asked Dec 18 '13 23:12

industrychanger


2 Answers

RectF rect = new RectF(currentRect);
like image 69
dymmeh Avatar answered Nov 12 '22 05:11

dymmeh


As "new" shouldn't be done in onDraw,

// As class fields,
Rect rect = new Rect();
RectF rectF = new RectF();

...
onDraw(Canvas canvas) {
    ...
    rectF.set(rect);
    ...
}
like image 37
Ebrahim Byagowi Avatar answered Nov 12 '22 04:11

Ebrahim Byagowi