From 8b7a068aeb3c7590a7342305e3e9b91c3a0a6b35 Mon Sep 17 00:00:00 2001 From: Brett Date: Mon, 13 May 2024 13:14:54 -0400 Subject: [PATCH] silly --- CMakeLists.txt | 2 +- include/graph_base.h | 66 ++++++++++++++++++++++++++++++++++ lib/BLT-With-Graphics-Template | 2 +- src/main.cpp | 61 +++++-------------------------- 4 files changed, 77 insertions(+), 54 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7c2375..b44669d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(graphs VERSION 0.0.37) +project(graphs VERSION 0.0.38) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/include/graph_base.h b/include/graph_base.h index dc464bf..c54d346 100644 --- a/include/graph_base.h +++ b/include/graph_base.h @@ -27,7 +27,9 @@ class node { private: blt::gfx::point2d_t point; + float outline_scale = 1.25f; blt::vec2 velocity; + blt::color4 outline_color = blt::make_color(0.0, 1.0, 1.0); public: explicit node(const blt::gfx::point2d_t& point): point(point) {} @@ -51,6 +53,26 @@ class node { return point; } + + [[nodiscard]] float getOutlineScale() const + { + return outline_scale; + } + + void setOutlineScale(float outlineScale) + { + outline_scale = outlineScale; + } + + [[nodiscard]] const blt::color4& getOutlineColor() const + { + return outline_color; + } + + void setOutlineColor(const blt::color4& c) + { + outline_color = c; + } }; @@ -58,6 +80,10 @@ class edge { private: blt::u64 i1, i2; + float outline_scale = 2.0f; + float thickness = 2.0f; + blt::color4 color = blt::make_color(0, 1, 0); + blt::color4 outline_color = blt::make_color(1, 0, 0); public: edge(blt::u64 i1, blt::u64 i2): i1(i1), i2(i2) { @@ -78,6 +104,46 @@ class edge { return i2; } + + [[nodiscard]] float getOutlineScale() const + { + return outline_scale; + } + + void setOutlineScale(float outlineScale) + { + outline_scale = outlineScale; + } + + [[nodiscard]] const blt::color4& getColor() const + { + return color; + } + + void setColor(const blt::color4& c) + { + color = c; + } + + [[nodiscard]] const blt::color4& getOutlineColor() const + { + return outline_color; + } + + void setOutlineColor(const blt::color4& outlineColor) + { + outline_color = outlineColor; + } + + [[nodiscard]] float getThickness() const + { + return thickness; + } + + void setThickness(float t) + { + thickness = t; + } }; struct edge_hash diff --git a/lib/BLT-With-Graphics-Template b/lib/BLT-With-Graphics-Template index 2c85c0f..7c82253 160000 --- a/lib/BLT-With-Graphics-Template +++ b/lib/BLT-With-Graphics-Template @@ -1 +1 @@ -Subproject commit 2c85c0f93c9028ae8db7b19c107af4b2fe4978a6 +Subproject commit 7c82253251e937b2caa9a0717b1008282d2200ce diff --git a/src/main.cpp b/src/main.cpp index cc4ed61..f58fc87 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -228,8 +228,10 @@ class graph_t for (const auto& point : nodes) { - auto draw_info = blt::gfx::render_info_t::make_info("parker_point", blt::make_color(0, 1, 1)); - renderer_2d.drawPointInternal(draw_info, point.getRenderObj(), 10.0f); + auto pr = point.getRenderObj(); + pr.scale *= point.getOutlineScale(); + renderer_2d.drawPointInternal(blt::gfx::render_info_t::make_info(point.getOutlineColor()), pr, 10.0f); + renderer_2d.drawPointInternal(blt::gfx::render_info_t::make_info("parker_point"), point.getRenderObj(), 15.0f); } for (const auto& edge : edges) { @@ -240,8 +242,11 @@ class graph_t { auto n1 = nodes[edge.getFirst()]; auto n2 = nodes[edge.getSecond()]; - auto draw_info = blt::gfx::render_info_t::make_info(blt::make_color(0, 1, 0), blt::make_color(1, 0, 0)); - renderer_2d.drawLine(draw_info, 5.0f, n1.getRenderObj().pos, n2.getRenderObj().pos, 2.0f); + auto draw_info = blt::gfx::render_info_t::make_info(edge.getColor()); + auto outline_info = blt::gfx::render_info_t::make_info(edge.getOutlineColor()); + blt::gfx::line2d_t line{n1.getRenderObj().pos, n2.getRenderObj().pos, edge.getThickness() * edge.getOutlineScale()}; + renderer_2d.drawLine(draw_info, 5.0f, n1.getRenderObj().pos, n2.getRenderObj().pos, edge.getThickness()); + renderer_2d.drawLineInternal(outline_info, line, 2.0f); } } } @@ -511,56 +516,8 @@ void update(const blt::gfx::window_data& data) fps = 1 / ft; } -void process_string(const std::string& str) -{ - BLT_DEBUG(str); - auto results = blt::template_engine_t::process_string(str); - if (results) - { - auto val = results.value(); - for (auto& v : val) - { - BLT_TRACE_STREAM << (blt::template_token_to_string(v.type)); - } - BLT_TRACE_STREAM << "\n"; - for (auto& v : val) - { - BLT_TRACE("{%s: %s}", blt::template_token_to_string(v.type).c_str(), std::string(v.token).c_str()); - } - } else - { - auto error = results.error(); - switch (error) - { - case blt::template_tokenizer_failure_t::MISMATCHED_CURLY: - BLT_ERROR("Tokenizer Failure: Mismatched curly"); - break; - case blt::template_tokenizer_failure_t::MISMATCHED_PAREN: - BLT_ERROR("Tokenizer Failure: Mismatched parenthesis"); - break; - case blt::template_tokenizer_failure_t::MISMATCHED_QUOTE: - BLT_ERROR("Tokenizer Failure: Mismatched Quotes"); - break; - } - - } - BLT_DEBUG("--------------------------"); -} - int main(int, const char**) { -// blt::template_engine_t templateEngine; -// templateEngine.set("LAYOUT_STRING", "layout (location = ${IF(LAYOUT_LOCATION) { LAYOUT_LOCATION } ELSE { ~DISCARD }}) "); -// templateEngine.set("LAYOUT_LOCATION", "1"); -// -// auto result = templateEngine.evaluate(shader_pp_screen_frag); -// -// if (result) -// BLT_TRACE(result.value()); -// else -// BLT_TRACE("Function Failed: %d", static_cast(result.error())); -// -// return 0; blt::gfx::init(blt::gfx::window_data{"Graphing Lovers United", init, update, 1440, 720}.setSyncInterval(1)); global_matrices.cleanup(); resources.cleanup();