summaryrefslogtreecommitdiff
path: root/src/modules/blinds
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2017-05-06 23:35:02 -0700
committerVito Caputo <vcaputo@pengaru.com>2022-04-19 18:33:22 -0700
commit98553eaa9b6d4d5bc03d59a6bec74f4877a620b5 (patch)
tree9ae138a1134d18b510666ce48edc1e97ca366e62 /src/modules/blinds
parent53d4d504b9103f524c50385ed3545fd08d0e272e (diff)
modules/blinds: add simple 80s-aesthetic window blinds
This isn't super interesting but I might just start adding simplistic overlay style modules for compositing/transition use.
Diffstat (limited to 'src/modules/blinds')
-rw-r--r--src/modules/blinds/Makefile.am3
-rw-r--r--src/modules/blinds/blinds.c45
2 files changed, 48 insertions, 0 deletions
diff --git a/src/modules/blinds/Makefile.am b/src/modules/blinds/Makefile.am
new file mode 100644
index 0000000..c1c1bfa
--- /dev/null
+++ b/src/modules/blinds/Makefile.am
@@ -0,0 +1,3 @@
+noinst_LTLIBRARIES = libblinds.la
+libblinds_la_SOURCES = blinds.c
+libblinds_la_CPPFLAGS = -I@top_srcdir@/src -I@top_srcdir@/src/libs
diff --git a/src/modules/blinds/blinds.c b/src/modules/blinds/blinds.c
new file mode 100644
index 0000000..080b468
--- /dev/null
+++ b/src/modules/blinds/blinds.c
@@ -0,0 +1,45 @@
+#include <math.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "til.h"
+#include "til_fb.h"
+
+/* Copyright (C) 2017-2022 Vito Caputo <vcaputo@pengaru.com> */
+
+#define NUM_BLINDS 16
+
+/* draw a blind over fragment */
+static inline void draw_blind(til_fb_fragment_t *fragment, unsigned row, float t)
+{
+ unsigned row_height = fragment->frame_height / NUM_BLINDS;
+ unsigned height = roundf(t * (float)row_height);
+
+ for (unsigned y = 0; y < height; y++)
+ memset(fragment->buf + ((row * row_height) + y ) * (fragment->pitch >> 2), 0xff, fragment->width * 4);
+}
+
+
+/* draw blinds over the fragment */
+static void blinds_render_fragment(void *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment)
+{
+ static float rr;
+
+ unsigned row;
+ float r;
+
+ til_fb_fragment_clear(fragment);
+
+ for (r = rr, row = 0; row < NUM_BLINDS; row++, r += .1)
+ draw_blind(fragment, row, 1.f - fabsf(cosf(r)));
+
+ rr += .01;
+}
+
+
+til_module_t blinds_module = {
+ .render_fragment = blinds_render_fragment,
+ .name = "blinds",
+ .description = "Retro 80s-inspired window blinds",
+ .author = "Vito Caputo <vcaputo@pengaru.com>",
+};
© All Rights Reserved