Better centered text. Pass by reference for midi variable is not going to work with json serialization.

This commit is contained in:
Sebastian
2024-12-15 03:17:10 +01:00
parent 96c2bde0e1
commit 996ed16c01
6 changed files with 42 additions and 38 deletions
+18
View File
@@ -0,0 +1,18 @@
#pragma once
#include "vmath.h"
#include <raymath.h>
#include <string>
namespace VISEQ::HELPER{
inline void DrawSuperText(std::string text, Vec2Df start, Vec2Df end, float pos, float dist, float size, Color col){
float d = start.dist(end);
Vector2 text_length = MeasureTextEx(GetFontDefault(), text.c_str(), size, 2.0f);
Vec2Df middle_handle = start + (end - start) * ((d - text_length.x)*pos)/d;
Vec2Df text_position = middle_handle + (start - end).norm().orth() * dist;
float rotation = Vector2Angle((Vector2){1,0}, (end - start)) * RAD2DEG;
DrawTextPro(GetFontDefault(), text.c_str(), text_position, (Vector2){0,0}, rotation, size, 2.0f, col);
}
}