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

CustomMarker add_path and get_compiled_path likely to fail on some backends #716

Open
corranwebster opened this issue Mar 13, 2021 · 2 comments

Comments

@corranwebster
Copy link
Contributor

This issue could alternatively be "Compiled Path API inconsistent between backends".

The issue here is that both of these methods on CustomMarker try to provide a copy of the custom marker's path scaled appropriately for the size of the marker. This relies on a call to CompiledPath.scale_ctm which is not available on all backends (eg. QPainter backend, celiagg backend) and in some cases (eg. QPainter) there doesn't look to be an easy way to provide that support.

As a result the call will fail.

In some cases add_path may still work in use because it is being used by passing in a GC instead of a path.

@jwiggins
Copy link
Member

I don't think CompiledPath has any reason to contain a transformation matrix.

That said, I think this should give the same result across backends:

from math import pi
with gc:
    gc.set_line_width(7)
    gc.set_stroke_color((1.0, 0.0, 1.0, 1.0))

    with gc:
        gc.translate_ctm(50, 50)
        for i in range(0, 12):
            gc.translate_ctm(20, 0)
            gc.rotate_ctm(2*pi/12.0)
            gc.move_to(0, 0)
            gc.line_to(20, 0)
        gc.stroke_path()

That is, when you're modifying the implicit path in a GraphicsContext the current transformation matrix is absolutely relevant. But kiva.agg can't have nice things (#390) because it does path transformation too early.

I don't think this necessarily precludes AbstractMarker.add_to_path from scaling markers.

@jwiggins
Copy link
Member

jwiggins commented Mar 18, 2021

Right. I played around with this a bit in celiagg... I don't think it's actually possible to do this for the implicit path. We could possibly add it to CompiledPath, but even that might be too confusing.

Based on the intractability of #390 for kiva.agg, I see this as a design bug in kiva.agg. We should refactor AbstractMarker so that it works with backends which implement transformation correctly.

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

No branches or pull requests

3 participants