java - How to approximate an ellipse to fill a given rectangle, using bezier curves? -


i tried code below, draws approximation of circle if rectangle's width same height; doesn't draw great oval, "corners" pointed. suggestions?

float width = rect.width(); float height = rect.height(); float centerx = rect.width() / 2; float centery = rect.height() / 2;  float diameter = math.min(width, height);  float length = (float) (0.5522847498 * diameter/2);   path.moveto(0, centery); path.cubicto(0, centery - length, 0, centerx - length, 0, centerx, 0); path.cubicto(centerx + length, 0, width, centery - length, height, centery); path.cubicto(width, centery + length, centerx + length, height, centerx, height); path.cubicto(centerx - length, height, 0, centery + length, 0, centery); 

you should scale length according axis it's on, distance each arc endpoint adjacent control points (not fixed but) fixed fraction of axis you're moving parallel @ point.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -