ASCII-GFX  2.0
util.h
Go to the documentation of this file.
1 // NCurses utility functions
2 // (c) 2020 by Stefan Roettger
3 
4 #pragma once
5 
6 #include <stddef.h>
7 #include "math2d.h"
8 
10 void msleep(float ms);
11 
13 float rnd();
14 
20 bool is_repeating(float time, float period,
21  float percent = 50);
22 
25 int strpre(const char *pre, const char *str);
26 
29 const char *get_arg(int n, int argc, char *argv[]);
30 
36 const char *get_opt(int n, int argc, char *argv[],
37  double *value = NULL, double default_value = 0);
38 
41 void log_text(const char *format, ...);
42 
44 void log_float(float v);
45 
47 void log_vec2(const Vec2 &v);
48 
50 void log_vec3(const Vec3 &v);
51 
53 void log_mat3(const Mat3 &m);
54 
56 void log_clear();
get_arg
const char * get_arg(int n, int argc, char *argv[])
retrieve the n-th argument from the command line arguments
Definition: util.cpp:49
log_vec3
void log_vec3(const Vec3 &v)
print 3D vector to log overlay
Definition: util.cpp:150
strpre
int strpre(const char *pre, const char *str)
check if a string starts with a prefix
Definition: util.cpp:43
log_text
void log_text(const char *format,...)
print log text in overlay
Definition: util.cpp:98
rnd
float rnd()
generate a random float number in the range [0,1[
Definition: util.cpp:21
Vec3
3D vector type
Definition: math2d.h:14
log_float
void log_float(float v)
print float value to log overlay
Definition: util.cpp:138
Vec2
2D vector type
Definition: math2d.h:7
log_clear
void log_clear()
clear log overlay
Definition: util.cpp:167
msleep
void msleep(float ms)
sleep for a period of time given in milli seconds
Definition: util.cpp:14
Mat3
3D matrix type
Definition: math2d.h:22
log_mat3
void log_mat3(const Mat3 &m)
print 3x3 matrix to log overlay
Definition: util.cpp:156
get_opt
const char * get_opt(int n, int argc, char *argv[], double *value=NULL, double default_value=0)
retrieve the n-th option from the command line arguments
Definition: util.cpp:65
math2d.h
is_repeating
bool is_repeating(float time, float period, float percent=50)
check for a repeating time period
Definition: util.cpp:35
log_vec2
void log_vec2(const Vec2 &v)
print 2D vector to log overlay
Definition: util.cpp:144