enable
enable copied to clipboard
kiva.agg backend doesn't scale line widths
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.

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.
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.
OK. I've fixed this in celiagg. It wasn't too hard. kiva.agg is a different story entirely. For context: https://github.com/enthought/enable/blob/8bc13b1709a7c32b7961ee11b3e2e903af9f70ee/kiva/agg/src/kiva_compiled_path.h#L29-L42
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.
This also affects HiDPI mode with the agg backend: lines are half the width they should be with the agg backend.
kiva.agg implemented transformations incorrectly and it's basically stuck now.