Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discrepancies in arc_to paths #985

Open
corranwebster opened this issue Aug 8, 2022 · 1 comment
Open

Discrepancies in arc_to paths #985

corranwebster opened this issue Aug 8, 2022 · 1 comment

Comments

@corranwebster
Copy link
Contributor

corranwebster commented Aug 8, 2022

When drawing a rounded rect using methods like the following:

def gen_rounded_rect_ccw(obj, x, y, w, h, r):
    obj.move_to(x + w/2, y)
    obj.arc_to(x + w, y, x + w, y + h/2, r)
    obj.arc_to(x + w, y + h, x + w / 2, y + h, r)
    obj.arc_to(x, y + h, x, y + h/2, r)
    obj.arc_to(x, y, x + w / 2, y, r)


def gen_rounded_rect_cw(obj, x, y, w, h, r):
    obj.move_to(x + w/2, y)
    obj.arc_to(x, y, x, y + h / 2, r)
    obj.arc_to(x, y + h, x + w / 2, y + h, r)
    obj.arc_to(x + w, y + h, x + w, y + h / 2, r)
    obj.arc_to(x + w, y, x + w / 2, y, r)

sometimes Kiva draws the entire boundary (eg. celiagg, qpainter, pdf backends):
image

and sometimes it does not (eg. agg, opengl, quartz backends):
image

I think given that the end point of the paths is the same as the start point, I think the first case is the correct one.

Also the PS and SVG backends fail completely to render (because basecore2d.GraphicsContext doesn't implement arc_to).

@corranwebster
Copy link
Contributor Author

From AbstractGraphicsContext:

   If the tangent point on the line from the current point to ``(x1, y1)``
   is not equal to the current point, a line is drawn to it. Depending on
   the supplied ``radius``, the tangent point on the line from
   ``(x1, y1)`` to ``(x2, y2)`` may or may not be ``(x2, y2)``. In either
   case, the arc is drawn to the point of tangency, which is also the new
   current point.

That implies that the second case is what is expected: the path goes to the tangent point, not (x2, y2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant