mirror of
https://github.com/ldericher/fftcgtool
synced 2025-01-15 23:03:00 +00:00
28 lines
643 B
Python
28 lines
643 B
Python
|
import queue
|
||
|
|
||
|
from .imageloader import ImageLoader
|
||
|
|
||
|
|
||
|
class Book:
|
||
|
def __init__(self, cards):
|
||
|
self.__cards = cards
|
||
|
|
||
|
def __get_pages(self, grid):
|
||
|
# cards per sheet
|
||
|
r, c = grid
|
||
|
capacity = r*c - 1
|
||
|
# flat copy
|
||
|
cards = self.__cards
|
||
|
|
||
|
# while there are cards
|
||
|
while cards:
|
||
|
# get a chunk
|
||
|
yield cards[:capacity]
|
||
|
# remove that chunk
|
||
|
cards = cards[capacity:]
|
||
|
|
||
|
def populate(self, grid, resolution, threadnum=16):
|
||
|
card_queue = queue.Queue()
|
||
|
for i, card in enumerate(self.__cards):
|
||
|
card_queue.put((i, card))
|