forked from reingart/pyfpdf
-
Notifications
You must be signed in to change notification settings - Fork 233
/
test_regular_polygon.py
70 lines (57 loc) · 2.22 KB
/
test_regular_polygon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from pathlib import Path
import fpdf
from test.conftest import assert_pdf_equal
HERE = Path(__file__).resolve().parent
def test_regular_polygon(tmp_path):
pdf = fpdf.FPDF()
pdf.add_page()
# no fill with line
pdf.regular_polygon(10, 35, 3, 25)
pdf.regular_polygon(40, 35, 4, 25)
pdf.regular_polygon(70, 35, 5, 25)
pdf.regular_polygon(100, 35, 6, 25)
pdf.regular_polygon(130, 35, 7, 25)
pdf.regular_polygon(160, 35, 8, 25)
# fill and color test
pdf.set_fill_color(134, 200, 15)
pdf.regular_polygon(10, 75, 3, 25, style="f")
pdf.regular_polygon(40, 75, 4, 25, style="f")
pdf.regular_polygon(70, 75, 5, 25, style="f")
pdf.regular_polygon(100, 75, 6, 25, style="f")
pdf.regular_polygon(130, 75, 7, 25, style="f")
pdf.regular_polygon(160, 75, 8, 25, style="f")
# draw color test
pdf.set_fill_color(0, 0, 0)
pdf.set_draw_color(204, 0, 204)
pdf.regular_polygon(10, 115, 3, 25)
pdf.regular_polygon(40, 115, 4, 25)
pdf.regular_polygon(70, 115, 5, 25)
pdf.regular_polygon(100, 115, 6, 25)
pdf.regular_polygon(130, 115, 7, 25)
pdf.regular_polygon(160, 115, 8, 25)
# line width test
pdf.set_line_width(1)
pdf.regular_polygon(10, 155, 3, 25)
pdf.regular_polygon(40, 155, 4, 25)
pdf.regular_polygon(70, 155, 5, 25)
pdf.regular_polygon(100, 155, 6, 25)
pdf.regular_polygon(130, 155, 7, 25)
pdf.regular_polygon(160, 155, 8, 25)
# line color and fill color
pdf.set_fill_color(3, 190, 252)
pdf.regular_polygon(10, 195, 3, 25, style="f")
pdf.regular_polygon(40, 195, 4, 25, style="f")
pdf.regular_polygon(70, 195, 5, 25, style="f")
pdf.regular_polygon(100, 195, 6, 25, style="f")
pdf.regular_polygon(130, 195, 7, 25, style="f")
pdf.regular_polygon(160, 195, 8, 25, style="f")
# rotation test
pdf.set_draw_color(0, 0, 255)
pdf.regular_polygon(10, 235, 3, 25, 30)
pdf.regular_polygon(40, 235, 4, 25, 45)
pdf.regular_polygon(70, 235, 5, 25, 200)
pdf.regular_polygon(100, 235, 6, 25, 0)
pdf.regular_polygon(130, 235, 7, 25, 13)
pdf.regular_polygon(160, 235, 8, 25, 22.5)
# pdf.output("test_regular_polygon.pdf")
assert_pdf_equal(pdf, HERE / "class_regular_polygon.pdf", tmp_path)