Created
September 3, 2022 10:27
-
-
Save ylashin/917569093241bdca1acdb460bd982995 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def adjust_file_info(file: FileInfo, item: DataItem): | |
if file.minx is None or file.minx > item.x: | |
file.minx = item.x | |
if file.miny is None or file.miny > item.y: | |
file.miny = item.y | |
if file.maxx is None or file.maxx < item.x: | |
file.maxx = item.x | |
if file.maxy is None or file.maxy < item.y: | |
file.maxy = item.y | |
def calculate_data_linear_placement(items: List[DataItem]): | |
files = {} | |
for index, item in enumerate(items): | |
order = index // 4 | |
if not order in files: | |
files[order] = FileInfo([]) | |
file = files[order] | |
file.items.append(item) | |
adjust_file_info(file, item) | |
return files | |
linear_organised_files = calculate_data_linear_placement(items) | |
pprint(linear_organised_files) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment