Creating oval/circle inside a rectangle

I am trying to create an oval/circle inside a rectangle. I am trying to do this on canvas for a bitmap image. Here is my code:

int x = (int) (midpoint.x*xRatio);
int y = (int) (midpoint.y*yRatio);
int radius = (int) (distance/2);
int left =  x - radius;
int right = x + radius;
int top = y - radius;

canvas.drawRect(left, top, right, bottom, paint);

Now i want to create an oval/circle inside this rectangle. I tried this and been trying for hours cant get it to work:

RectF ovalBounds = new RectF();
//ovalBounds.set(x, y,  (right - left)/2, (bottom-top)/2);
ovalBounds.set(x, y-radius, radius * 2, radius * 2);
canvas.drawOval(ovalBounds, paint);                 

Can someone please help me figure this out? Here is visual to help what i am trying to achieve:

Answers


You should use the same bounds than you used for drawing the rectangle:

RectF rect = new RectF(left, top, right, bottom);
canvas.drawRect(rect, paint);
canvas.drawOval(rect, paint);

Need Your Help

Android generic property

java android ios generics reflection

I have on object, where one property should be possible go store generic objects. All this objects extend a basic class "BaseObject".

What kind of authorization I should use for my facebook application

python django oauth google-api gdata-api

I am building a social reader Facebook application using Django where I am using Google Data API (Blogger API). But I am unable to deal with the authorization step to use the Google API (currently ...