cmdfx 0.1.0
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
util.h File Reference

Cross-Platform Utilities for CmdFX. More...

Go to the source code of this file.

Functions

unsigned long currentTimeMillis ()
 Gets the current time in milliseconds.
 
unsigned long long currentTimeNanos ()
 Gets the current time in nanoseconds.
 
void sleepMillis (unsigned long millis)
 Pauses the program for a specified number of milliseconds.
 
void sleepNanos (unsigned long long nanos)
 Pauses the program for a specified number of nanoseconds.
 
double clamp_d (double value, double min, double max)
 Clamps a value between a minimum and maximum.
 
float clamp_f (float value, float min, float max)
 Clamps a value between a minimum and maximum.
 
int clamp_i (int value, int min, int max)
 Clamps a value between a minimum and maximum.
 
double lerp_d (double a, double b, double t)
 Linearly interpolates between two values.
 
float lerp_f (float a, float b, float t)
 Linearly interpolates between two values.
 
int lerp_i (int a, int b, double t)
 Linearly interpolates between two values.
 
void rgb_to_hsv (int rgb, double *h, double *s, double *v)
 Converts an RGB color to HSV.
 
int hsv_to_rgb (double h, double s, double v)
 Converts an HSV color to RGB.
 
int lerp_color (int rgb1, int rgb2, double t)
 Linearly interpolates between two colors.
 

Detailed Description

Cross-Platform Utilities for CmdFX.

Author
Gregory Mitchell (me@gm.nosp@m.itch.nosp@m.215.x.nosp@m.yz)
Version
0.1.0
Date
2025-01-21

Function Documentation

◆ clamp_d()

double clamp_d ( double value,
double min,
double max )

Clamps a value between a minimum and maximum.

Parameters
valueThe value to clamp.
minThe minimum value.
maxThe maximum value.
Returns
The clamped value.

◆ clamp_f()

float clamp_f ( float value,
float min,
float max )

Clamps a value between a minimum and maximum.

Parameters
valueThe value to clamp.
minThe minimum value.
maxThe maximum value.
Returns
The clamped value.

◆ clamp_i()

int clamp_i ( int value,
int min,
int max )

Clamps a value between a minimum and maximum.

Parameters
valueThe value to clamp.
minThe minimum value.
maxThe maximum value.
Returns
The clamped value.

◆ currentTimeMillis()

unsigned long currentTimeMillis ( )

Gets the current time in milliseconds.

Returns
The current time in milliseconds.

◆ currentTimeNanos()

unsigned long long currentTimeNanos ( )

Gets the current time in nanoseconds.

Returns
The current time in nanoseconds.

◆ hsv_to_rgb()

int hsv_to_rgb ( double h,
double s,
double v )

Converts an HSV color to RGB.

Parameters
hThe hue.
sThe saturation.
vThe value.
Returns
The RGB color.

◆ lerp_color()

int lerp_color ( int rgb1,
int rgb2,
double t )

Linearly interpolates between two colors.

Parameters
rgb1The first color in RGB format.
rgb2The second color in RGB format.
tThe interpolation factor.
Returns
The interpolated color.

◆ lerp_d()

double lerp_d ( double a,
double b,
double t )

Linearly interpolates between two values.

Parameters
aThe first value.
bThe second value.
tThe interpolation factor.
Returns
The interpolated value.

◆ lerp_f()

float lerp_f ( float a,
float b,
float t )

Linearly interpolates between two values.

Parameters
aThe first value.
bThe second value.
tThe interpolation factor.
Returns
The interpolated value.

◆ lerp_i()

int lerp_i ( int a,
int b,
double t )

Linearly interpolates between two values.

Parameters
aThe first value.
bThe second value.
tThe interpolation factor.
Returns
The interpolated value.

◆ rgb_to_hsv()

void rgb_to_hsv ( int rgb,
double * h,
double * s,
double * v )

Converts an RGB color to HSV.

Parameters
rgbThe RGB color.
hThe pointer to the hue.
sThe pointer to the saturation.
vThe pointer to the value.

◆ sleepMillis()

void sleepMillis ( unsigned long millis)

Pauses the program for a specified number of milliseconds.

Parameters
millisThe number of milliseconds to pause.

◆ sleepNanos()

void sleepNanos ( unsigned long long nanos)

Pauses the program for a specified number of nanoseconds.

Parameters
nanosThe number of nanoseconds to pause.