43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#include <cmath>
|
|
#include <algorithm>
|
|
|
|
#include "Math.hpp"
|
|
#include "values/mrand.hpp"
|
|
|
|
#include <raymath.h>
|
|
|
|
Color ColorLerp(Color c1, Color c2, float amount)
|
|
{
|
|
Color ret{0};
|
|
ret.r = Clamp(Lerp(c1.r, c2.r, amount), 0, 255);
|
|
ret.g = Clamp(Lerp(c1.g, c2.g, amount), 0, 255);
|
|
ret.b = Clamp(Lerp(c1.b, c2.b, amount), 0, 255);
|
|
ret.a = Clamp(Lerp(c1.a, c2.a, amount), 0, 255);
|
|
return ret;
|
|
}
|
|
|
|
Color ColorAdd(Color c, int add)
|
|
{
|
|
int r = std::clamp(c.r + add, 0, 255);
|
|
int g = std::clamp(c.g + add, 0, 255);
|
|
int b = std::clamp(c.b + add, 0, 255);
|
|
|
|
return {(unsigned char)r, (unsigned char)g, (unsigned char)b, c.a};
|
|
}
|
|
|
|
Vector2 CalculateVector(float rotation, float offSet, float len)
|
|
{
|
|
float angle = ((rotation)*PI) / 180.0f;
|
|
angle += offSet;
|
|
return {
|
|
.x = len * std::sin(angle),
|
|
.y = len * std::cos(angle)};
|
|
}
|
|
|
|
void drawTexureWithRotation(RenderTexture2D &target, Rectangle &dest, float rotation)
|
|
{
|
|
Rectangle source = {0, 0, (float)target.texture.width, (float)-target.texture.height};
|
|
Vector2 origin = {0.0f, 0.0f};
|
|
rotation = 360 - rotation;
|
|
DrawTexturePro(target.texture, source, dest, origin, rotation, WHITE);
|
|
} |