numerics 0.1.0
Loading...
Searching...
No Matches
viz.hpp File Reference

Lightweight real-time visualization layer for numerics apps. More...

#include <raylib.h>
#include <raymath.h>
#include <algorithm>
#include <cstdint>
#include <cstdarg>
#include <cstdio>
#include <vector>

Go to the source code of this file.

Classes

struct  num::viz::Color
 
struct  num::viz::detail::FieldCanvas
 
struct  num::viz::detail::State
 
struct  num::viz::Frame
 
struct  num::viz::Frame::Cam3
 

Namespaces

namespace  num
 
namespace  num::viz
 
namespace  num::viz::detail
 

Functions

inline ::Color num::viz::to_rl (Color c)
 
Color num::viz::from_rl (::Color c)
 
Color num::viz::unpack (uint32_t c)
 
Color num::viz::heat_color (float t)
 t in [0,1]: blue -> cyan -> yellow -> red.
 
Color num::viz::diverging_color (float t)
 t in [-1,1]: deep blue -> black -> deep red.
 
Color num::viz::phase_hsv_color (double prob, double phase, double max_prob)
 Quantum wavefunction: hue = phase, brightness = sqrt(|psi|^2 / max).
 
Color num::viz::lerp_color (Color a, Color b, float t)
 Linear blend between two colors.
 
template<class DrawFn >
void num::viz::run (const char *title, int w, int h, DrawFn draw, Color bg={15, 15, 15, 255})
 

Variables

constexpr Color num::viz::kBlack = {0, 0, 0, 255}
 
constexpr Color num::viz::kWhite = {255, 255, 255, 255}
 
constexpr Color num::viz::kRed = {220, 40, 40, 255}
 
constexpr Color num::viz::kGreen = {50, 200, 50, 255}
 
constexpr Color num::viz::kBlue = {50, 100, 230, 255}
 
constexpr Color num::viz::kYellow = {240, 220, 30, 255}
 
constexpr Color num::viz::kGray = {120, 120, 120, 255}
 
constexpr Color num::viz::kSkyBlue = {100, 180, 240, 255}
 

Detailed Description

Lightweight real-time visualization layer for numerics apps.

Wraps raylib behind a single draw-callback interface. Every app has the same shape:

#include "viz.hpp"
num::viz::run("My Sim", 900, 900, [&](num::viz::Frame& f) {
f.step([&]{ sim.step(dt); }); // SPACE pauses, +/- adjusts
substeps for (int i = 0; i < n; ++i)
f.dot(x[i], y[i], heat_color(T[i]));
});
void run(const char *title, int w, int h, DrawFn draw, Color bg={15, 15, 15, 255})
Definition viz.hpp:348
void dot(float x, float y, Color c, float r=3.0f)
Definition viz.hpp:204
void step(Fn fn)
Definition viz.hpp:192
Lightweight real-time visualization layer for numerics apps.

This header is NOT included by numerics.hpp – it depends on raylib which is an optional app-layer dependency. Include it directly from your app.

Controls (built-in)

SPACE pause / unpause R reset (check f.reset_pressed() in your callback) +/- increase / decrease substeps ESC quit

Definition in file viz.hpp.