-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Clip small linewidths in agg #14560
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
base: main
Are you sure you want to change the base?
Clip small linewidths in agg #14560
Conversation
src/_backend_agg.h
Outdated
// Too small linewidths are clipped because they require a lot of | ||
// computation and do not make sense even with antialiasing. | ||
// Compare github #14498. | ||
linewidth = (linewidth < 0.01) ? 0.01 : mpl_round(linewidth); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess clipping at 1/256 would make sense because the quantization of the channels is 8bit so linewidths<1/256 (or half that? perhaps...) would be quantized to zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are channels in this context? I only know color channels but don't see how that could be related to linewidth.
Anyways, 0.01 causes some image comparison failures, trying 0.001 to see if that fixes it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant color channels.
With antialiasing, linewidths<1 are basically represented by setting the color channels to (linewidthreal_color) (blending with the background), but that's then quantized to 8 bits so linewidths<1/(2256) should result in nothing being drawn.
ed7f647
to
514484a
Compare
Still 44 image comparison failures for a cutoff at 0.001. Needs to be investigated, ... later. |
Possibly clip small linewidths to zero (i.e. don't draw them at all) instead of 0.001? just a random idea... |
514484a
to
82b0415
Compare
Try forcing linewidth < 0.001 to 0. |
Interestingly, forcing linewidth < 0.001 to 0 causes a lot of image comparison failures with dashed lines having slightly modified widths. |
Anybody can pick this up if wanted. I don't have the time to debug this for now. |
PR Summary
Fixes #14498. See there for a full discussion.
Note: I've noticed that the following code uses a mixture of
gc.linewidth
(the original value) andlinewidth
(the clipped value). Can somebody with more Agg knowledge please check if that is correct?