mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-20 08:54:15 +00:00
080667ae62
useful.h -> color_lerp(): - added documentation in comments - changed default value for gamma from 2.2 to 2.0 hitbox_visualizer.hpp -> ATTACK_replace(): - slightly modified formula for changing effect color based on damage
42 lines
1.3 KiB
C
42 lines
1.3 KiB
C
#ifndef USEFUL_H
|
|
#define USEFUL_H
|
|
|
|
#include <switch.h>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
|
|
#include "l2c.hpp"
|
|
|
|
#define LINKABLE __attribute__ ((weak))
|
|
|
|
#define debug_log(...) \
|
|
{char log_buf[0x200]; snprintf(log_buf, 0x200, __VA_ARGS__); \
|
|
svcOutputDebugString(log_buf, strlen(log_buf));}
|
|
|
|
/**
|
|
* Rounds a number to the nearest multiple of another number.
|
|
*/
|
|
float round_to(float val, float align);
|
|
|
|
/**
|
|
* Linearly interpolates between two numbers, without bounds checking.
|
|
*/
|
|
float lerp(float min, float max, float t);
|
|
float unlerp(float min, float max, float val);
|
|
/**
|
|
* Linearly interpolates between two numbers, with bounds checking.
|
|
*/
|
|
float lerp_bounded(float min, float max, float t);
|
|
float unlerp_bounded(float min, float max, float val);
|
|
|
|
/**
|
|
* Linearly nterpolates between two colors, with bounds checking, accounting for gamma.
|
|
* arguments:
|
|
* - min_color (Vector3f) -- xyz maps to rgb, components are usually in the range [0.0f, 1.0f] but can go beyond to account for super-bright or super-dark colors
|
|
* - max_Color (Vector3f) -- same as minColor
|
|
* - t (float) -- how far to interpolate between the colors
|
|
* - gamma (float = 2.0f) -- used for color correction, helps avoid ugly dark colors when interpolating b/t bright colors
|
|
*/
|
|
Vector3f color_lerp(Vector3f min_color, Vector3f max_color, float t, float gamma = 2.0f);
|
|
|
|
#endif // USEFUL_H
|