abg

Animated background for X11
git clone git://git.laack.co/abg.git
Log | Files | Refs | README

commit 20c9236b320c3e67709833dc88efb3bd4a0f50ad
parent 27a69afb31f1b2bbf19f6c9d7a715b52c41b7cd0
Author: Andrew Laack <andrew@laack.co>
Date:   Tue, 15 Sep 2026 10:08:24 -0500

Fixed perf issue; it was the png conversion that was so slow

Diffstat:
Mbackground/src/graph.cpp | 6+++---
Mbackground/src/main.cpp | 18++++++++++--------
2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/background/src/graph.cpp b/background/src/graph.cpp @@ -18,7 +18,7 @@ Graph::Graph(std::size_t edgeCount, std::size_t vertCount, uint32_t xMax, uint32 for(std::size_t i = 0; i < vertCount; ++i) { Vector2 rnd = randomPosition(xMax, yMax); - Vertex v {rnd,5}; + Vertex v {rnd,2}; this->vertices.push_back(v); } for(std::size_t i = 0; i < edgeCount; ++i) { @@ -75,7 +75,7 @@ void Graph::render() { if(edge.traversed) { visited.push_back(edge); } else { - DrawLineEx(v1, v2, 1,DARKERGRAY); + DrawLineEx(v1, v2, .2,DARKERGRAY); } } } @@ -90,7 +90,7 @@ void Graph::render() { std::size_t idx2 = edge.v2Index; auto v1 = vertices[idx1].position; auto v2 = vertices[idx2].position; - DrawLineEx(v1, v2, 1, WHITE); + DrawLineEx(v1, v2, .2, WHITE); } } diff --git a/background/src/main.cpp b/background/src/main.cpp @@ -20,11 +20,11 @@ int main() { std::filesystem::create_directory("/dev/shm/bg"); srand(clock()); - std::size_t edgeCount = 30; - std::size_t vertCount = 10; + std::size_t edgeCount = 20000; + std::size_t vertCount = 4000; - float xMax = 5120; - float yMax = 1440; + uint32_t xMax = 5120; + uint32_t yMax = 1440; SetConfigFlags(FLAG_WINDOW_HIDDEN); InitWindow(xMax, yMax, "Raylib animation window"); @@ -44,17 +44,19 @@ int main() { visitedIndices.insert(0); while (!WindowShouldClose() && toVisit.size() != 0) { - sleep(5); - + sleep(10); BeginDrawing(); ClearBackground(BLACK); g.render(); EndDrawing(); - char path[] = "/dev/shm/bg/out.png"; + // Basically all of the cost happens within these bounds + char path[] = "/dev/shm/bg/out.bmp"; CustomTakeScreenshot(path); // TODO: Can this be done away with? It's not *that* slow... - system("/usr/bin/feh --no-fehbg --bg-tile /dev/shm/bg/out.png"); + system("/usr/bin/feh --no-fehbg --bg-scale /dev/shm/bg/out.bmp"); + // Above here. + oneStepPrim(toVisit, visitedIndices, g); }