-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPage.py
More file actions
59 lines (51 loc) · 2.31 KB
/
Page.py
File metadata and controls
59 lines (51 loc) · 2.31 KB
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
class Position:
def __init__(self,x,y):
self.isEpmty = True
self.position = [float(x),float(y)]
#centerOfHorizontal = 210 / 2
#centerOfVertical = 297 / 2
#widthOfCardsRow = cardwidth * cardCountOnHorizontal + spaceBetweenOnHorizontal * (cardCountOnHorizontal - 1)
#heightOfCardsCol = cardwidth * cardCountOnHorizontal + spaceBetweenOnHorizontal * (cardCountOnHorizontal - 1)
class SinglePage:
#default Single pdff page
def __init__(self,cardWidth = 57,cardHeight = 89,cardCountOnHorizontal = 3,cardCountOnVertical = 3,spaceBetweenOnHorizontal = 5,spaceBetweenOnVertical = 5,shiftBack = 0):
self.countOfFreePositions = 0
centerOfHorizontal = 210 / 2
centerOfVertical = 297 / 2
widthOfCardsRow = cardWidth * cardCountOnHorizontal + (spaceBetweenOnHorizontal * (cardCountOnHorizontal - 1))
heightOfCardsCol = cardHeight * cardCountOnVertical + (spaceBetweenOnVertical * (cardCountOnVertical - 1))
#default count of cards with grid 3x3
leftBorder = centerOfHorizontal - widthOfCardsRow/2
upBorder = centerOfVertical - heightOfCardsCol/2 - shiftBack
if cardCountOnVertical == -3 and cardCountOnHorizontal == -33:
self.positions = [
Position(0,0),Position(float(cardWidth),0),Position(float(cardWidth)*2,0),
Position(0,float(cardHeight)),Position(float(cardWidth),float(cardHeight)),Position(float(cardWidth)*2,float(cardHeight)),
Position(0,float(cardHeight)*2),Position(float(cardWidth),float(cardHeight)*2),Position(float(cardWidth)*2,float(cardHeight)*2)
]
else:
#must restore only x
self.positions = []
nextColCardIndex = int(0)
for y in range(int(cardCountOnVertical)):
for x in range(int(cardCountOnHorizontal)):
if y == 0 and x == 0:
self.positions.append(Position(leftBorder,upBorder))
else:
self.positions.append(Position(leftBorder + x* (cardWidth + int(spaceBetweenOnHorizontal)),upBorder + y *(cardHeight+ float(spaceBetweenOnVertical))))
nextColCardIndex+=1
nextColCardIndex = 0
def isPageFull(self):
for pos in self.positions:
if pos.isEpmty == True:
self.countOfFreePositions += 1
if self.countOfFreePositions == 0:
return True
else:
self.countOfFreePositions = 0
return False
def getLastFreePos(self):
for pos in self.positions:
if pos.isEpmty == True:
pos.isEpmty = False
return pos.position