New Unit: au (=36px)

This commit is contained in:
Dominik Moritz Roth 2022-12-06 12:52:32 +01:00
parent 1bf587c4da
commit ede0f80cea
2 changed files with 7 additions and 3 deletions

View File

@ -513,7 +513,7 @@ class ColumbusConfigDefined(ColumbusEnv):
if s.replace('.', '', 1).isdigit(): if s.replace('.', '', 1).isdigit():
return True return True
num, unit = s[:-2], s[-2:] num, unit = s[:-2], s[-2:]
if unit in ['px', 'em', 'rx', 'ry', 'ct']: if unit in ['px', 'em', 'rx', 'ry', 'ct', 'au']:
if num.replace('.', '', 1).isdigit(): if num.replace('.', '', 1).isdigit():
return True return True
return False return False
@ -538,6 +538,8 @@ class ColumbusConfigDefined(ColumbusEnv):
em = num em = num
elif unit == 'px': elif unit == 'px':
em = num / ({'x': self.width, 'y': self.height}[axis]) em = num / ({'x': self.width, 'y': self.height}[axis])
elif unit == 'au':
em = num * 36 / ({'x': self.width, 'y': self.height}[axis])
elif unit == 'ct': elif unit == 'ct':
em = num / 100 em = num / 100
else: else:

View File

@ -6,13 +6,15 @@ name: "DEFAULT"
# ct: 100ct = Full Width / Height # ct: 100ct = Full Width / Height
# rx: pixels relative to width # rx: pixels relative to width
# ry: pixels relative to height # ry: pixels relative to height
# au: 1au = 36px
# #
# When no unit is given, we use the folowing defaults # When no unit is given, we use the folowing defaults
# (compatible with legacy behavior) # (compatible with legacy behavior)
# pos: em # pos: em
# all other: px # all other: px
# #
# ct is the recommendet unit... # ct is the recommendet unit.
# If you need a unit, that is not responsive in regards to width/height, use au / px.
params: params:
task: task:
@ -70,7 +72,7 @@ params:
pos: [0.75em, 90px] pos: [0.75em, 90px]
- type: OnceReward - type: OnceReward
reward: 100 reward: 100
radius: 3ct radius: 1au
pos: [0.3, 0.8] # defaults to em pos: [0.3, 0.8] # defaults to em
start_pos: [90ct, 20ct] start_pos: [90ct, 20ct]
default_collision_elasticity: 0.8 default_collision_elasticity: 0.8