ASCII-GFX  2.0
Functions | Variables
util.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "gfx.h"
#include "scrollarea.h"

Functions

void msleep (float ms)
 sleep for a period of time given in milli seconds More...
 
float rnd ()
 generate a random float number in the range [0,1[ More...
 
bool is_repeating (float time, float period, float percent)
 check for a repeating time period More...
 
int strpre (const char *pre, const char *str)
 check if a string starts with a prefix More...
 
const char * get_arg (int n, int argc, char *argv[])
 retrieve the n-th argument from the command line arguments More...
 
const char * get_opt (int n, int argc, char *argv[], double *value, double default_value)
 retrieve the n-th option from the command line arguments More...
 
void log_text (const char *format,...)
 print log text in overlay More...
 
void log_float (float v)
 print float value to log overlay More...
 
void log_vec2 (const Vec2 &v)
 print 2D vector to log overlay More...
 
void log_vec3 (const Vec3 &v)
 print 3D vector to log overlay More...
 
void log_mat3 (const Mat3 &m)
 print 3x3 matrix to log overlay More...
 
void log_clear ()
 clear log overlay More...
 

Variables

static int log_line = 0
 

Function Documentation

◆ get_arg()

const char* get_arg ( int  n,
int  argc,
char *  argv[] 
)

retrieve the n-th argument from the command line arguments

  • options starting with - or – are omitted

◆ 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

  • arguments not starting with - or – are omitted
  • if the option contains a = followed by a decimal value,
  • then the value is returned by reference,
  • else a default value is returned

◆ is_repeating()

bool is_repeating ( float  time,
float  period,
float  percent = 50 
)

check for a repeating time period

  • "time" is the actual time
  • "period" is the repeating time period
  • return value is true for the first "percent" of each period
  • by default the return value is true for the first half of the period

◆ log_clear()

void log_clear ( )

clear log overlay

◆ log_float()

void log_float ( float  v)

print float value to log overlay

◆ log_mat3()

void log_mat3 ( const Mat3 m)

print 3x3 matrix to log overlay

◆ log_text()

void log_text ( const char *  format,
  ... 
)

print log text in overlay

  • log text is given in printf format style

◆ log_vec2()

void log_vec2 ( const Vec2 v)

print 2D vector to log overlay

◆ log_vec3()

void log_vec3 ( const Vec3 v)

print 3D vector to log overlay

◆ msleep()

void msleep ( float  ms)

sleep for a period of time given in milli seconds

◆ rnd()

float rnd ( )

generate a random float number in the range [0,1[

◆ strpre()

int strpre ( const char *  pre,
const char *  str 
)

check if a string starts with a prefix

  • return value is eqivalent to strncmp

Variable Documentation

◆ log_line

int log_line = 0
static