commit 98374cda43a22616ba5ca2399bdcd19435665e8d
parent 20c9236b320c3e67709833dc88efb3bd4a0f50ad
Author: Andrew Laack <andrew@laack.co>
Date: Tue, 15 Sep 2026 10:10:47 -0500
Define constants for vertex size + edge for rendering
Diffstat:
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/background/src/graph.cpp b/background/src/graph.cpp
@@ -6,6 +6,9 @@
#include <raylib.h>
#include <stdexcept>
+#define VERTEX_SIZE 5
+#define EDGE_SIZE 1
+
Graph::Graph(std::size_t edgeCount, std::size_t vertCount, uint32_t xMax, uint32_t yMax) {
if(edgeCount > 0 && vertCount <= 1) {
@@ -18,7 +21,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,2};
+ Vertex v {rnd,VERTEX_SIZE};
this->vertices.push_back(v);
}
for(std::size_t i = 0; i < edgeCount; ++i) {
@@ -75,7 +78,7 @@ void Graph::render() {
if(edge.traversed) {
visited.push_back(edge);
} else {
- DrawLineEx(v1, v2, .2,DARKERGRAY);
+ DrawLineEx(v1, v2, EDGE_SIZE,DARKERGRAY);
}
}
}
@@ -90,7 +93,7 @@ void Graph::render() {
std::size_t idx2 = edge.v2Index;
auto v1 = vertices[idx1].position;
auto v2 = vertices[idx2].position;
- DrawLineEx(v1, v2, .2, WHITE);
+ DrawLineEx(v1, v2, EDGE_SIZE, WHITE);
}
}
diff --git a/background/src/main.cpp b/background/src/main.cpp
@@ -20,8 +20,8 @@ int main() {
std::filesystem::create_directory("/dev/shm/bg");
srand(clock());
- std::size_t edgeCount = 20000;
- std::size_t vertCount = 4000;
+ std::size_t edgeCount = 2000;
+ std::size_t vertCount = 100;
uint32_t xMax = 5120;
uint32_t yMax = 1440;