summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/modules/Makefile.am2
-rw-r--r--src/modules/blinds/Makefile.am3
-rw-r--r--src/modules/blinds/blinds.c45
-rw-r--r--src/til.c2
5 files changed, 52 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index aa42c08..a676ce4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,7 +3,7 @@ SUBDIRS = libs modules
noinst_LTLIBRARIES = libtil.la
libtil_la_SOURCES = til_args.c til_args.h til_fb.c til_fb.h til_knobs.h til.c til.h til_settings.h til_settings.c til_threads.c til_threads.h til_util.c til_util.h
libtil_la_CPPFLAGS = -I@top_srcdir@/src
-libtil_la_LIBADD = modules/compose/libcompose.la modules/drizzle/libdrizzle.la modules/flui2d/libflui2d.la modules/julia/libjulia.la modules/meta2d/libmeta2d.la modules/montage/libmontage.la modules/pixbounce/libpixbounce.la modules/plasma/libplasma.la modules/plato/libplato.la modules/ray/libray.la modules/roto/libroto.la modules/rtv/librtv.la modules/snow/libsnow.la modules/sparkler/libsparkler.la modules/spiro/libspiro.la modules/stars/libstars.la modules/submit/libsubmit.la modules/swab/libswab.la modules/swarm/libswarm.la libs/grid/libgrid.la libs/puddle/libpuddle.la libs/ray/libray.la libs/sig/libsig.la libs/txt/libtxt.la libs/ascii/libascii.la libs/din/libdin.la
+libtil_la_LIBADD = modules/blinds/libblinds.la modules/compose/libcompose.la modules/drizzle/libdrizzle.la modules/flui2d/libflui2d.la modules/julia/libjulia.la modules/meta2d/libmeta2d.la modules/montage/libmontage.la modules/pixbounce/libpixbounce.la modules/plasma/libplasma.la modules/plato/libplato.la modules/ray/libray.la modules/roto/libroto.la modules/rtv/librtv.la modules/snow/libsnow.la modules/sparkler/libsparkler.la modules/spiro/libspiro.la modules/stars/libstars.la modules/submit/libsubmit.la modules/swab/libswab.la modules/swarm/libswarm.la libs/grid/libgrid.la libs/puddle/libpuddle.la libs/ray/libray.la libs/sig/libsig.la libs/txt/libtxt.la libs/ascii/libascii.la libs/din/libdin.la
if ENABLE_ROTOTILLER
bin_PROGRAMS = rototiller
diff --git a/src/modules/Makefile.am b/src/modules/Makefile.am
index 28fc7fd..c791bc9 100644
--- a/src/modules/Makefile.am
+++ b/src/modules/Makefile.am
@@ -1 +1 @@
-SUBDIRS = compose drizzle flui2d julia meta2d montage pixbounce plasma plato ray roto rtv snow sparkler spiro stars submit swab swarm
+SUBDIRS = blinds compose drizzle flui2d julia meta2d montage pixbounce plasma plato ray roto rtv snow sparkler spiro stars submit swab swarm
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>",
+};
diff --git a/src/til.c b/src/til.c
index 651a23a..c5cced8 100644
--- a/src/til.c
+++ b/src/til.c
@@ -23,6 +23,7 @@
static til_threads_t *til_threads;
+extern til_module_t blinds_module;
extern til_module_t compose_module;
extern til_module_t drizzle_module;
extern til_module_t flui2d_module;
@@ -44,6 +45,7 @@ extern til_module_t swab_module;
extern til_module_t swarm_module;
static const til_module_t *modules[] = {
+ &blinds_module,
&compose_module,
&drizzle_module,
&flui2d_module,
© All Rights Reserved