Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonhc authored and Lucas-C committed Dec 27, 2024
1 parent 20ade32 commit c1c4479
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
Binary file added test/pattern/radial_gradient.pdf
Binary file not shown.
40 changes: 37 additions & 3 deletions test/pattern/test_radial_gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,42 @@
HERE = Path(__file__).resolve().parent


def test_radial_gradient(tmp_path):
pdf = FPDF()
pdf.add_page()
x = pdf.w / 2 - 25
y = pdf.get_y()
with pdf.use_pattern(
RadialGradient(
pdf,
x + 25,
y + 25,
0,
x + 25,
y + 25,
25,
[(255, 255, 0), (255, 0, 0)],
)
):
pdf.circle(x=x + 25, y=y + 25, radius=25, style="FD")
y += 60
with pdf.use_pattern(
RadialGradient(
pdf,
x + 5,
y + 5,
0,
x + 25,
y + 25,
25,
[(255, 255, 0), (255, 0, 0)],
)
):
pdf.circle(x=x + 25, y=y + 25, radius=25, style="FD")

assert_pdf_equal(pdf, HERE / "radial_gradient.pdf", tmp_path)


def test_radial_gradient_multiple_colors(tmp_path):
pdf = FPDF()
pdf.add_page()
Expand Down Expand Up @@ -40,6 +76,4 @@ def test_radial_gradient_multiple_colors(tmp_path):
):
pdf.rect(x=x, y=y, w=pdf.epw, h=100, style="FD")

assert_pdf_equal(
pdf, HERE / "radial_gradient_multiple_colors.pdf", tmp_path, generate=True
)
assert_pdf_equal(pdf, HERE / "radial_gradient_multiple_colors.pdf", tmp_path)

0 comments on commit c1c4479

Please sign in to comment.