treender/src/Math.cpp
Nikola Petrov 2b2dfe751e Simplify
calculation of canvas position based on the cursor position and expected rotation
2024-04-01 22:56:57 +02:00

22 lines
557 B
C++

#include <cmath>
#include "Math.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;
}
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)};
}