Force Units in px to be integers (rounding down)

This commit is contained in:
2022-12-06 12:09:19 +01:00
parent bde7869f97
commit 8132bb9321
2 changed files with 8 additions and 1 deletions
+3 -1
View File
@@ -855,6 +855,8 @@ class ColumbusConfigDefined(ColumbusEnv):
if type(s) in [int, float]:
return s
if s.replace('.', '', 1).isdigit():
if target == 'px':
return int(s)
return float(s)
num, unit = s[:-2], s[-2:]
num = float(num)
@@ -876,7 +878,7 @@ class ColumbusConfigDefined(ColumbusEnv):
if target == 'em':
return em
elif target == 'px':
return em * ({'x': self.width, 'y': self.height}[axis])
return int(em * ({'x': self.width, 'y': self.height}[axis]))
def setup(self):
self.agent.pos = self.start_pos