-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshape.py
More file actions
66 lines (32 loc) · 935 Bytes
/
Copy pathshape.py
File metadata and controls
66 lines (32 loc) · 935 Bytes
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
import pymupdf
doc = pymupdf.open()
doc.new_page()
print("Draw a Shape\n")
print("1. Line")
print("2. Rectangle")
print("3. Circle")
snum = input("Shape #: ")
page = doc[0]
if(snum == "1"):
shape = page.new_shape()
pt1 = input("Point 1 (x,y): ").split(",")
pt2 = input("Point 2 (x,y): ").split(",")
shape.draw_line(pymupdf.Point(int(pt1[0]),int(pt1[1])),pymupdf.Point(int(pt2[0]),int(pt2[1])))
shape.commit()
elif(snum == "2"):
shape = page.new_shape()
rc = input("Rectangle: (x0,y0,x1,y1): ")
rect = rc.split(",")
shape.draw_rect(pymupdf.Rect(*rect))
shape.commit()
elif(snum == "3"):
shape = page.new_shape()
rd = input("Center: (x,y)").split(",")
radius = input("Radius: ")
shape.draw_circle(pymupdf.Point(*rd))
shape.commit()
else:
print("Not supported")
exported = input("Exported: ")
doc.ez_save(exported)
doc.close()