Python Pil - Transparent And Dashed Lines?
Solution 1:
First, replace grid = 'on'
with a boolean. You should be using True
or False
, not string comparisons, to check if the setting is enabled with if grid:
.
Second, PIL doesn't have the ability to draw dashed lines by default. To draw a dashed line you have to draw several small lines spaced apart from each other. However, for what you're trying to do, dashed lines should not be necessary; Setting the opacity of a line can be done with a high degree of control.
Finally, you should be able to achieve very fine control over the opacity of the lines with your approach. The gridlines()
function is doing a lot of extra work; It redraws the image for no reason, draws text, etc. So what's most likely going on is your grid lines are being drawn over each other several times, causing them to get more and more opaque.
If it turns our your grid drawing is fine, then you should save your image as a PNG, not a JPEG. JPEG does not render red very well since it's designed to save photographic imagery and that means it dedicates more information to storing greens and blues, which our eyes see more of.
Post a Comment for "Python Pil - Transparent And Dashed Lines?"