summaryrefslogtreecommitdiff
path: root/opplysning.c
diff options
context:
space:
mode:
authorMartin Stensgård <mastensg@mastensg.net>2025-04-20 23:27:35 +0200
committerMartin Stensgård <mastensg@mastensg.net>2025-04-20 23:27:35 +0200
commit81aa75359d1444747331f0b48def800219d46db2 (patch)
treeccf81cf24ebc97b91259b7377ef0e258ca8de4ed /opplysning.c
parent79c96a5dabdb5e062b89e90d70ed36cd215300bc (diff)
press f to effect text
Diffstat (limited to 'opplysning.c')
-rw-r--r--opplysning.c36
1 files changed, 34 insertions, 2 deletions
diff --git a/opplysning.c b/opplysning.c
index 7155a2c..57e90b1 100644
--- a/opplysning.c
+++ b/opplysning.c
@@ -109,11 +109,32 @@ const char *the_alphabet = "0123456789"
"ÄÅÉËÞÜÚÍÓÖÁSSÐFGHÏŒØÆŒ©®BÑΜ"
"äåéëþüúíóöáßðfghïœøæœ©®bñµ"
"!@#$%^&*()[];'\\:\"|,./<>?";
+Shader the_shader;
+RenderTexture2D the_target;
+int the_shader_u_time;
void
+blur(int x, int y, Font f, Color c, char *s)
+{
+ const int sh = 1080;
+ Vector2 m = MeasureTextEx(f, s, f.baseSize, 0);
+
+ BeginTextureMode(the_target);
+ ClearBackground((Color){0});
+ DrawTextEx(f, s, (Vector2){0, 0}, (float)f.baseSize, 0, c);
+ EndTextureMode();
+
+ BeginShaderMode(the_shader);
+ float t = GetTime();
+ SetShaderValue(the_shader, the_shader_u_time, &t, SHADER_UNIFORM_FLOAT);
+ DrawTextureRec(the_target.texture, (Rectangle){0, sh - m.y, m.x, -m.y},
+ (Vector2){x, y}, WHITE);
+ EndShaderMode();
+}
+void
line(int x, int y, Font f, Color c, char *s)
{
- DrawTextEx(f, s, (Vector2){x, y}, (float)f.baseSize, 2, c);
+ DrawTextEx(f, s, (Vector2){x, y}, (float)f.baseSize, 0, c);
}
int
@@ -140,6 +161,11 @@ main(void)
Color fg = BLACK;
Color hd = {0xf0, 0x4a, 0x00, 0xff};
+ the_shader = LoadShader(0, "s.glsl");
+ the_shader_u_time = GetShaderLocation(the_shader, "u_time");
+ the_target = LoadRenderTexture(sw, sh);
+ int fx = 0;
+
while (!WindowShouldClose()) {
struct timespec now = {0};
clock_gettime(CLOCK_REALTIME, &now);
@@ -147,6 +173,9 @@ main(void)
char ts[64] = {0};
snprintf(ts, sizeof(ts), "%02d:%02d", ti->tm_hour, ti->tm_min);
+ if (IsKeyPressed(KEY_F))
+ fx = !fx;
+
BeginDrawing();
ClearBackground(bg);
Vector2 v2_ts = MeasureTextEx(font_h, ts, font_h.baseSize, 0);
@@ -166,7 +195,10 @@ main(void)
snprintf(s, sizeof(s), "%s %u. %s",
ukedag[e->wday], e->day,
maaned[e->month]);
- line(25, y += 50, font_h, hd, s);
+ if (fx)
+ blur(25, y += 50, font_h, hd, s);
+ else
+ line(25, y += 50, font_h, hd, s);
y += 20;
}
{