From 4e36337007d817a4e82b9ac7fb7dd48475ac0380 Mon Sep 17 00:00:00 2001 From: Darren Ranalli Date: Wed, 27 Nov 2002 19:11:41 +0000 Subject: [PATCH] added bound --- direct/src/showbase/PythonUtil.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index 68460701f0..a3d077266d 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -496,3 +496,13 @@ class Functor: _kargs = self._kargs.copy() _kargs.update(kargs) return apply(self._function,_args,_kargs) + +def bound(value, bound1, bound2): + """ + returns value if value is between bound1 and bound2 + otherwise returns bound that is closer to value + """ + if bound1 > bound2: + return min(max(value, bound2), bound1) + else: + return min(max(value, bound1), bound2)