numerics 0.1.0
Loading...
Searching...
No Matches
num::viz Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  Color
 
struct  Frame
 

Functions

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

Variables

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

Function Documentation

◆ diverging_color()

Color num::viz::diverging_color ( float  t)
inline

t in [-1,1]: deep blue -> black -> deep red.

Definition at line 74 of file viz.hpp.

◆ from_rl()

Color num::viz::from_rl ( ::Color  c)
inline

Definition at line 56 of file viz.hpp.

References num::viz::Color::r.

Referenced by heat_color().

◆ heat_color()

Color num::viz::heat_color ( float  t)
inline

t in [0,1]: blue -> cyan -> yellow -> red.

Definition at line 68 of file viz.hpp.

References from_rl().

◆ lerp_color()

Color num::viz::lerp_color ( Color  a,
Color  b,
float  t 
)
inline

Linear blend between two colors.

Definition at line 135 of file viz.hpp.

References num::viz::Color::a, num::viz::Color::b, num::viz::Color::g, and num::viz::Color::r.

◆ phase_hsv_color()

Color num::viz::phase_hsv_color ( double  prob,
double  phase,
double  max_prob 
)
inline

Quantum wavefunction: hue = phase, brightness = sqrt(|psi|^2 / max).

Definition at line 86 of file viz.hpp.

References num::e, and kBlack.

◆ run()

template<class DrawFn >
void num::viz::run ( const char *  title,
int  w,
int  h,
DrawFn  draw,
Color  bg = {15, 15, 15, 255} 
)

Definition at line 348 of file viz.hpp.

◆ to_rl()

◆ unpack()

Color num::viz::unpack ( uint32_t  c)
inline

Definition at line 61 of file viz.hpp.

Variable Documentation

◆ kBlack

constexpr Color num::viz::kBlack = {0, 0, 0, 255}
inlineconstexpr

Definition at line 43 of file viz.hpp.

Referenced by phase_hsv_color().

◆ kBlue

constexpr Color num::viz::kBlue = {50, 100, 230, 255}
inlineconstexpr

Definition at line 47 of file viz.hpp.

◆ kGray

constexpr Color num::viz::kGray = {120, 120, 120, 255}
inlineconstexpr

Definition at line 49 of file viz.hpp.

◆ kGreen

constexpr Color num::viz::kGreen = {50, 200, 50, 255}
inlineconstexpr

Definition at line 46 of file viz.hpp.

◆ kRed

constexpr Color num::viz::kRed = {220, 40, 40, 255}
inlineconstexpr

Definition at line 45 of file viz.hpp.

◆ kSkyBlue

constexpr Color num::viz::kSkyBlue = {100, 180, 240, 255}
inlineconstexpr

Definition at line 50 of file viz.hpp.

◆ kWhite

constexpr Color num::viz::kWhite = {255, 255, 255, 255}
inlineconstexpr

Definition at line 44 of file viz.hpp.

◆ kYellow

constexpr Color num::viz::kYellow = {240, 220, 30, 255}
inlineconstexpr

Definition at line 48 of file viz.hpp.