UPDATE: Moved mapping functions to dedicated coordinate manager class

This commit is contained in:
2025-03-11 19:28:29 +01:00
parent cbda94373d
commit a954e8f163

12
coordinate_manager.py Normal file
View File

@@ -0,0 +1,12 @@
def mapped_value(value, in_min, in_max, out_min, out_max):
return (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
class CoordinateManager:
def __init__(self, width, height):
self.width = width
self.height = height
def coord_to_pixel(self, x, y):
mapped_x = mapped_value(x, -4000, 4000, 0, self.width)
mapped_y = mapped_value(y, -4000, 4000, 0, self.height)
return mapped_x, mapped_y