Open Lucas-C opened 3 weeks ago
For the record, there is the current workaround that I currently use:
from fpdf import FPDF, FPDF_VERSION
minor, patch = map(int, FPDF_VERSION.split(".")[1:])
if minor < 7 or (minor == 7 and patch <= 9):
print("Using workaround for https://github.com/py-pdf/fpdf2/issues/1245")
class CustomFPDF(FPDF):
def circle(self, x, y, r, style=None):
super().circle(x-r, y-r, 2*r, style)
else:
CustomFPDF = FPDF
If it was only the r
problem I would say create a new radius
parameter and deprecate r
to be removed in the future, but compounding with x
and y
behavior I'd say it's a case where it's not worth keeping backwards compatibility.
Thank you for your feedback @andersonhc 👍
When the
FPDF.circle()
method was added, back in the summer of 2021 and version 2.4.2 offpdf2
, I think we missed a couple of details:r
parameter sets in fact the diameter of the circle! 😲x
&y
parameters refer to the top-left corner of the circle, instead of its center, as it's the case in almost all librariesMinimal code
What do we do now? Now, the question is: how should we fix this while preserving backward compatibility, as much as possible?
Given that we have a parameter named
r
that is in fact a diameter, I suggest that for this specific case we do not bother too much with backward compatibility, and just fix this issue (r
becoming the actual radius &x
/y
becoming the circle center) and inform our end-users by mentioning it in ourCHANGELOG.md
What do you think @gmischler & @andersonhc?