font3d_blender_addon/common/utils.py

19 lines
544 B
Python
Raw Normal View History

2024-05-21 18:00:49 +02:00
import time
import datetime
def get_timestamp():
return datetime.datetime \
.fromtimestamp(time.time()) \
.strftime('%Y.%m.%d-%H:%M:%S')
def mapRange(in_value, in_min, in_max, out_min, out_max, clamp=False):
output = out_min + ((out_max - out_min) / (in_max - in_min)) * (in_value - in_min)
if clamp:
if out_min < out_max:
return min(out_max, max(out_min, output))
else:
return max(out_max, min(out_min, output))
else:
return output