diff --git a/bin/xss-dimmer b/bin/xss-dimmer index ab1e9c3..deb3699 100755 --- a/bin/xss-dimmer +++ b/bin/xss-dimmer @@ -115,9 +115,30 @@ easing_functions = { "ease-out-quint": lambda x: 1 - pow(1 - x, 5), "ease-out-expo": lambda x: 1 - pow(2, -10 * x), "ease-out-quad": lambda x: 1 - (1 - x) * (1 - x), + "ease-out-bounce": ( + lambda n1, d1: lambda x: n1 * x * x + if x < 1 / d1 + else n1 * pow(x - 1.5 / d1, 2) + 0.75 + if x < 2 / d1 + else n1 * pow(x - 2.25 / d1, 2) + 0.9375 + if (x < 2.5 / d1) + else n1 * pow(x - 2.625 / d1, 2) + 0.984375 + )(7.5625, 2.75), "ease-out-elastic": ( lambda x: pow(2, -10 * x) * math.sin((x * 10 - 0.75) * (2 * math.pi) / 3) + 1 ), + "ease-inout-quad": lambda x: 2 * x * x if x < 0.5 else 1 - pow(-2 * x + 2, 2) / 2, + "ease-inout-quart": ( + lambda x: 8 * x * x * x * x if x < 0.5 else 1 - pow(-2 * x + 2, 4) / 2 + ), + "ease-inout-expo": ( + lambda x: pow(2, 20 * x - 10) / 2 if x < 0.5 else (2 - pow(2, -20 * x + 10)) / 2 + ), + "ease-inout-bounce": ( + lambda x: (1 - easing_functions["ease-out-bounce"](1 - 2 * x)) / 2 + if x < 0.5 + else (1 + easing_functions["ease-out-bounce"](2 * x - 1)) / 2 + ), } if __name__ == "__main__": @@ -133,7 +154,7 @@ if __name__ == "__main__": add("--background", help="use a background instead of black") add( "--easing-function", - default="ease-out-circ", + default="ease-out-bounce", choices=easing_functions.keys(), help="easing function for opacity", )