cmdfx 0.1.0
Lightweight game engine for your terminal
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1
11#pragma once
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17// Time
18
23unsigned long currentTimeMillis();
24
29unsigned long long currentTimeNanos();
30
35void sleepMillis(unsigned long millis);
36
41void sleepNanos(unsigned long long nanos);
42
43// Math
44
52double clamp_d(double value, double min, double max);
53
61float clamp_f(float value, float min, float max);
62
70int clamp_i(int value, int min, int max);
71
79double lerp_d(double a, double b, double t);
80
88float lerp_f(float a, float b, float t);
89
97int lerp_i(int a, int b, double t);
98
106void rgb_to_hsv(int rgb, double* h, double* s, double* v);
107
115int hsv_to_rgb(double h, double s, double v);
116
124int lerp_color(int rgb1, int rgb2, double t);
125
126#ifdef __cplusplus
127}
128#endif
double lerp_d(double a, double 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 lerp_i(int a, int b, double t)
Linearly interpolates between two values.
float lerp_f(float a, float b, float t)
Linearly interpolates between two values.
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.
float clamp_f(float value, float min, float max)
Clamps a value between a minimum and maximum.
unsigned long currentTimeMillis()
Gets the current time in milliseconds.
void sleepMillis(unsigned long millis)
Pauses the program for a specified number of milliseconds.
int clamp_i(int value, int min, int max)
Clamps a value between a minimum and maximum.
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.
unsigned long long currentTimeNanos()
Gets the current time in nanoseconds.