From 7bdce37fd3f18e2712e18c4e2c64cac69af0aca1 Mon Sep 17 00:00:00 2001 From: Jakob Stendahl Date: Sun, 19 Sep 2021 19:43:11 +0200 Subject: :boom: Introduce new UI based on svelte, and rewrite a lot of the node app and the NeoRuntime --- NeoRuntime/builtin/fade/script.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 NeoRuntime/builtin/fade/script.py (limited to 'NeoRuntime/builtin/fade/script.py') diff --git a/NeoRuntime/builtin/fade/script.py b/NeoRuntime/builtin/fade/script.py new file mode 100644 index 0000000..c88650d --- /dev/null +++ b/NeoRuntime/builtin/fade/script.py @@ -0,0 +1,8 @@ +from luxcena_neo import NeoBehaviour +import time + +class Main(NeoBehaviour): + + def on_start(self): + pass + -- cgit v1.2.3 From 9d8ab6ccd04530188caf9a24467e7374bc3c68cf Mon Sep 17 00:00:00 2001 From: Jakob Stendahl <14180120+JakobST1n@users.noreply.github.com> Date: Mon, 11 Oct 2021 09:08:42 +0200 Subject: :lipstick: Add fade script --- NeoRuntime/builtin/fade/script.py | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'NeoRuntime/builtin/fade/script.py') diff --git a/NeoRuntime/builtin/fade/script.py b/NeoRuntime/builtin/fade/script.py index c88650d..8fe902a 100644 --- a/NeoRuntime/builtin/fade/script.py +++ b/NeoRuntime/builtin/fade/script.py @@ -1,8 +1,28 @@ -from luxcena_neo import NeoBehaviour -import time +from luxcena_neo import NeoBehaviour, IntegerVariable + +def wheel(pos): + """Generate rainbow colors across 0-255 positions.""" + if pos < 85: + return (pos * 3, 255 - pos * 3, 0) + elif pos < 170: + pos -= 85 + return (255 - pos * 3, 0, pos * 3) + else: + pos -= 170 + return (0, pos * 3, 255 - pos * 3) class Main(NeoBehaviour): + def declare_variables(self): + self.declare(IntegerVariable("speed", 2, min_val=1, max_val=50)) + def on_start(self): - pass + """ Execute when mode is selected. """ + self.i = 0 + def each_tick(self): + self.i += self.var.speed + if self.i > 255: self.i = 0 + for i in range(strip.num_pixels()): + strip.set_pixel_color(i, wheel(self.i)) + strip.show() -- cgit v1.2.3