-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaper.py
More file actions
executable file
·28 lines (22 loc) · 984 Bytes
/
paper.py
File metadata and controls
executable file
·28 lines (22 loc) · 984 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
#!/usr/bin/env python3
import math
def size(paper_size,orientation):
paper_sizes = ["A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","A10"]
orientations = ["portrait", "landscape"]
assert paper_size in paper_sizes, "Paper size muse be one of %s"%" ".join(paper_sizes)
assert orientation in orientations, "Orientation must be either portrait or landscape"
paper_type = paper_size[0]
if paper_type == "A":
i = int(paper_size[1:])
a_const = 1.0 * math.pow(2.0,1/4)
w = a_const*math.pow( 2, -(i+1)/2 )
h = a_const*math.pow( 2, -i/2 )
if orientation == "landscape":
w,h = h,w
return w,h
if __name__ == "__main__":
print("Hello There!")
for orientation in ["portrait", "landscape"]:
for paper_size in ["A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","A10"]:
w,h = size(paper_size,orientation)
print("%s %s %ix%imm"%(orientation,paper_size,round(w*1000),round(h*1000)))