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

kiva.agg backend doesn't scale line widths #390

Open
corranwebster opened this issue Feb 15, 2020 · 4 comments
Open

kiva.agg backend doesn't scale line widths #390

corranwebster opened this issue Feb 15, 2020 · 4 comments

Comments

@corranwebster
Copy link
Contributor

When rendering with the QPainter backend, or other backends like the PDF backend, scaling is applied to rendered lines, so they get wider (seed the PDF below, which the rectangle has been scaled by (2, 1) vs. the same image rendered with the agg backend.

test.pdf

test

This inconsistency will possibly create problems as appearance may be different on different backends, or may be problematic when trying to save a report including a Chaco plot or similar.

@jwiggins
Copy link
Member

I think I might know how to fix this in celiagg, but not necessarily in kiva.agg. This article is a very lucid explanation of how the rasterization pipeline of AGG works.

If this can be fixed, then the solution will involve wrapping the VertexSource object as late as possible by conv_transform. Or at the very least, making sure conv_transform is wrapped around conv_stroke so that transformation happens after the stroke geometry is created.

@jwiggins
Copy link
Member

OK. I've fixed this in celiagg. It wasn't too hard. kiva.agg is a different story entirely. For context:

/*-------------------------------------------------------------------
This extends the standard agg24::path_storage class to include
matrix transforms within the path definition. Doing so requires
overriding a number of methods to apply the matrix transformation
to vertices added to the path.
The overridden methods are:
move_to
line_to
add_path
curve3
curve4
add_path

Basically what's going on in kiva.agg is that the path of kiva::graphics_context_base holds the affine transformation for the whole graphics context. (that's right) So as points are added to the path, they are transformed by the current, er, transform. Then when rasterizing a path, no transform needs to be used because the path's points are already where they need to be. This is different than Quartz, QPainter, celiagg, and probably other vector graphics libraries. I'm not sure why it was done this way in kiva.agg (performance?). But the takeaway is that fixing this bug is a much larger refactor and much riskier than the one required for celiagg.

@jwiggins jwiggins changed the title Agg backends don't scale line widths kiva.agg backend doesn't scale line widths Mar 23, 2021
@corranwebster
Copy link
Contributor Author

This also affects HiDPI mode with the agg backend: lines are half the width they should be with the agg backend.

@jwiggins
Copy link
Member

kiva.agg implemented transformations incorrectly and it's basically stuck now.

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

2 participants