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

Make sure all kiva backends implement AbstractGraphicsContext faithfully #648

Open
1 of 12 tasks
jwiggins opened this issue Mar 1, 2021 · 3 comments
Open
1 of 12 tasks
Labels
ETS Backlog Good issue for ETS team members to look at type: refactor

Comments

@jwiggins
Copy link
Member

jwiggins commented Mar 1, 2021

Since AbstractGraphicsContext is the published and documented interface for kiva backends, we should make sure that all current backends actually use that interface.

@jwiggins jwiggins added type: refactor ETS Backlog Good issue for ETS team members to look at labels Mar 1, 2021
@jwiggins jwiggins changed the title Make sure all kiva backends implement the AbstractGraphicsContext faithfully Make sure all kiva backends implement AbstractGraphicsContext faithfully Mar 2, 2021
@corranwebster
Copy link
Contributor

The PDF, PS, and SVG backends have no CompiledPath

All the backends that inherit from basecore2d can use the Agg CompiledPath implementation, but they don't expose it in the module API:

enable/kiva/basecore2d.py

Lines 704 to 743 in dae67fe

def add_path(self, path):
"""Draw a compiled path into this gc. Note: if the CTM is
changed and not restored to the identity in the compiled path,
the CTM change will continue in this GC."""
# Local import to avoid a dependency if we can avoid it.
from kiva import agg
multi_state = 0 # For multi-element path commands we keep the previous
x_ctrl1 = 0 # information in these variables.
y_ctrl1 = 0
x_ctrl2 = 0
y_ctrl2 = 0
for x, y, cmd, flag in path._vertices():
if cmd == agg.path_cmd_line_to:
self.line_to(x, y)
elif cmd == agg.path_cmd_move_to:
self.move_to(x, y)
elif cmd == agg.path_cmd_stop:
self.concat_ctm(path.get_kiva_ctm())
elif cmd == agg.path_cmd_end_poly:
self.close_path()
elif cmd == agg.path_cmd_curve3:
if multi_state == 0:
x_ctrl1 = x
y_ctrl1 = y
multi_state = 1
else:
self.quad_curve_to(x_ctrl1, y_ctrl1, x, y)
multi_state = 0
elif cmd == agg.path_cmd_curve4:
if multi_state == 0:
x_ctrl1 = x
y_ctrl1 = y
multi_state = 1
elif multi_state == 1:
x_ctrl2 = x
y_ctrl2 = y
multi_state = 2
elif multi_state == 2:
self.curve_to(x_ctrl1, y_ctrl1, x_ctrl2, y_ctrl2, x, y)

@jwiggins
Copy link
Member Author

I'm pretty averse to creating new dependencies on the Agg backend. We should consider a different way.

@corranwebster
Copy link
Contributor

This isn't new, just noting that there is a default implementation.

I agree thought: I'd really like a pure python implementation of CompiledPath, together with a proper definition of the expected interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ETS Backlog Good issue for ETS team members to look at type: refactor
Projects
None yet
Development

No branches or pull requests

2 participants