Skip to content

Instantly share code, notes, and snippets.

@ylashin
Created September 3, 2022 10:27
Show Gist options
  • Save ylashin/917569093241bdca1acdb460bd982995 to your computer and use it in GitHub Desktop.
Save ylashin/917569093241bdca1acdb460bd982995 to your computer and use it in GitHub Desktop.
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