From 561f9ec1036044dc831679ea0aac80abae4106b9 Mon Sep 17 00:00:00 2001 From: Snuckey <47194400+Snuckey@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:06:40 -0700 Subject: [PATCH] App that shows tv static and a channel number in the top right corner (#1899) --- apps/tvstatic/manifest.yaml | 8 +++++ apps/tvstatic/tv_static.star | 59 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 apps/tvstatic/manifest.yaml create mode 100644 apps/tvstatic/tv_static.star diff --git a/apps/tvstatic/manifest.yaml b/apps/tvstatic/manifest.yaml new file mode 100644 index 000000000..3154357e8 --- /dev/null +++ b/apps/tvstatic/manifest.yaml @@ -0,0 +1,8 @@ +--- +id: tv-static +name: TV Static +summary: Show static on an old TV +desc: Make your Tidbyt look like it is showing static on an old TV that is turned to Channel 3. +author: Snuckey +fileName: tv_static.star +packageName: tvstatic diff --git a/apps/tvstatic/tv_static.star b/apps/tvstatic/tv_static.star new file mode 100644 index 000000000..eac6c7da4 --- /dev/null +++ b/apps/tvstatic/tv_static.star @@ -0,0 +1,59 @@ +""" +Applet: TV Static +Summary: Show static on an old TV +Description: Make your Tidbyt look like it is showing static on an old TV that is turned to Channel 3. +Author: Snuckey +""" + +load("random.star", "random") +load("render.star", "render") + +STATIC_DIM = 2 + +def main(): + return render.Root( + child = render.Stack( + children = [ + render.Animation( + children = staticFrames(), + ), + render.Row( + children = [ + render.Text(content = "03", color = "#00ff00", font = "10x20"), + ], + main_align = "end", + expanded = True, + ), + ], + ), + ) + +def staticFrames(): + frames = [] + for _ in range(200): + frames.append(staticScreen()) + return frames + +def staticScreen(): + static = [] + + for _ in range(int(32 / STATIC_DIM)): + static.append(render.Row(children = staticRow())) + + return render.Column(children = static) + +def staticRow(): + static = [] + color = "" + + for _ in range(int(64 / STATIC_DIM)): + num = random.number(0, 2) + + if num == 0: + color = "#000000" + else: + color = "#ffffff" + + static.append(render.Box(width = STATIC_DIM, height = STATIC_DIM, color = color)) + + return static