jtmm2/src/util.c

53 lines
698 B
C
Raw Normal View History

2021-12-17 00:20:39 +01:00
#include "util.h"
2021-12-20 12:06:32 +01:00
#include <gint/display.h>
2021-12-17 00:20:39 +01:00
int
sign(int x)
{
return (x > 0) - (x < 0);
}
2021-12-18 10:05:52 +01:00
float
absf(float x)
{
return x * (-1 + 2 * (x > 0));
}
2021-12-19 11:48:17 +01:00
float
minf(float x, float y)
{
return (x < y) ? (x) : (y);
}
float
maxf(float x, float y)
{
return (x > y) ? (x) : (y);
}
2021-12-20 12:06:32 +01:00
int
min(int x, int y)
{
return (x < y) ? (x) : (y);
}
int
max(int x, int y)
{
return (x > y) ? (x) : (y);
}
void
dputs_outline(int x, int y, int halign, int valign, const char *text)
{
int rx = 2;
while (rx-- > -1) {
int ry = 2;
while (ry-- > -1) {
dprint_opt(x + rx, y + ry, C_WHITE, C_NONE, halign,
valign, "%s", text);
}
}
dprint_opt(x, y, C_BLACK, C_NONE, halign, valign, "%s", text);
}