Adding and fixing stuff

- Fix HexChar2Int
- Remove some devisions in tween engine
- Add PathAdd function for x, y seperated instead of fvec2
- Readd text wrapping (rd7-palladium maybe)
This commit is contained in:
2025-12-15 22:16:19 +01:00
parent f19c947fc3
commit 6c38aa6f21
6 changed files with 56 additions and 17 deletions

View File

@@ -31,10 +31,10 @@ namespace PD {
*/
namespace Strings {
constexpr int HexChar2Int(char c) {
/** Imagine mat hat ne lookup table dafür verwendet :/ */
/** Imagine man hat ne lookup table dafür verwendet :/ */
if (c >= '0' && c <= '9') return c - '0';
if (c >= 'a' && c <= 'f') return 10 + (c - 'a');
if (c >= 'A' && c <= 'F') return 10 + (c - 'a');
if (c >= 'A' && c <= 'F') return 10 + (c - 'A');
return -1; // Error
}
/**

View File

@@ -60,7 +60,7 @@ class Tween {
* @param delta deltatime
*/
void Update(float delta) {
time += delta / 1000.f;
time += delta * 0.001f;
if (time > tend) {
finished = true;
time = tend;
@@ -162,10 +162,10 @@ class Tween {
return -(end - start) * t * (t - 2) + start;
break;
case EaseInOutQuad:
t = time / (tend / 2);
if (t < 1) return (end - start) / 2 * t * t + start;
t = time / (tend * 0.5f);
if (t < 1) return (end - start) * 0.5f * t * t + start;
t--;
return -(end - start) / 2 * (t * (t - 2) - 1) + start;
return -(end - start) * 0.5f * (t * (t - 2) - 1) + start;
break;
case EaseInCubic:
t = time / tend;
@@ -177,20 +177,20 @@ class Tween {
return (end - start) * (t * t * t + 1) + start;
break;
// case EaseInOutCubic:
// t = time / (tend / 2);
// if (t < 1) return (end - start) / 2 * t * t * t + start;
// t = time / (tend *0.5f);
// if (t < 1) return (end - start) *0.5f * t * t * t + start;
// t--;
// return (end - start) / 2 * (t * t * t * 2) + start;
// return (end - start) *0.5f * (t * t * t * 2) + start;
// break;
case EaseInSine:
return -(end - start) * cos(time / tend * (M_PI / 2)) + (end - start) +
start;
return -(end - start) * cos(time / tend * (M_PI * 0.5f)) +
(end - start) + start;
break;
case EaseOutSine:
return (end - start) * sin(time / tend * (M_PI / 2)) + start;
return (end - start) * sin(time / tend * (M_PI * 0.5f)) + start;
break;
case EaseInOutSine:
return -(end - start) / 2 * (cos(M_PI * time / tend) - 1) + start;
return -(end - start) * 0.5f * (cos(M_PI * time / tend) - 1) + start;
break;
default: // Linear

View File

@@ -97,7 +97,7 @@ class PD_LITHIUM_API DrawList {
* Extended Draw Text Function
*/
void DrawTextEx(const fvec2& p, const std::string& text, u32 color,
LiTextFlags flags, fvec2 box = fvec2(0.f));
LiTextFlags flags, const fvec2& box = fvec2(0.f));
void DrawLine(const fvec2& a, const fvec2& b, u32 color, int t = 1);
/**
* Take list of points and display it as a line on screen
@@ -138,6 +138,14 @@ class PD_LITHIUM_API DrawList {
* @param v Position to add
*/
void PathAdd(const fvec2& v) { pPath.Add(v); }
/**
* Add a Point to the Path
* @note Keep in mind that this function is used for
* setting the starting point
* @param x X Position to add
* @param y Y Position to add
*/
void PathAdd(float x, float y) { pPath.Add(fvec2(x, y)); }
/**
* Path Stroke Create Line from point to point
* @note For Primitives like Rect or Triangle mak sure to use

View File

@@ -101,6 +101,8 @@ class PD_LITHIUM_API Font {
*/
void pMakeAtlas(bool final, std::vector<u8>& font_tex, int texszs,
PD::Li::Texture::Ref tex);
std::string pWrapText(const std::string& txt, float scale,
const PD::fvec2& max, PD::fvec2& dim);
/** Data Section */
int PixelHeight;