remove Math
This commit is contained in:
parent
e50acd9cc5
commit
6f227026b9
@ -1,5 +0,0 @@
|
|||||||
#include <raylib.h>
|
|
||||||
|
|
||||||
Color ColorAdd(Color c1, Color c2);
|
|
||||||
Color ColorAddValue(Color c, int add);
|
|
||||||
Rectangle TextInSpace(Rectangle box, float textH, float textW, float margin, bool topOrBottom);
|
|
39
src/App.cpp
39
src/App.cpp
@ -2,7 +2,6 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "App.hpp"
|
#include "App.hpp"
|
||||||
#include "Math.hpp"
|
|
||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <raymath.h>
|
#include <raymath.h>
|
||||||
@ -10,6 +9,44 @@
|
|||||||
#define TOP (1 - pos)
|
#define TOP (1 - pos)
|
||||||
#define BOTTOM pos
|
#define BOTTOM pos
|
||||||
|
|
||||||
|
Rectangle TextInSpace(Rectangle box, float textH, float textW, float margin, bool topOrBottom)
|
||||||
|
{
|
||||||
|
float br = box.width / box.height;
|
||||||
|
float tr = textW / textH;
|
||||||
|
|
||||||
|
Rectangle ret = {0, 0, 0, 0};
|
||||||
|
|
||||||
|
float hm = box.height * margin;
|
||||||
|
float wm = box.width * margin;
|
||||||
|
|
||||||
|
ret.height = box.height - hm;
|
||||||
|
ret.width = box.width - wm;
|
||||||
|
|
||||||
|
if (br < tr)
|
||||||
|
{
|
||||||
|
// bolj kvadrat izracunaj visino iz sirine
|
||||||
|
ret.height = ret.width / tr;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// bolj podolgovat izracunaj sirino iz visine
|
||||||
|
ret.width = ret.height * tr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (topOrBottom)
|
||||||
|
{
|
||||||
|
ret.y = box.y + hm;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret.y = box.y + box.height - hm - ret.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.x = box.x + wm;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// Dimentions for font size 20
|
// Dimentions for font size 20
|
||||||
// DISLIKE 83
|
// DISLIKE 83
|
||||||
// LIKE 46
|
// LIKE 46
|
||||||
|
64
src/Math.cpp
64
src/Math.cpp
@ -1,64 +0,0 @@
|
|||||||
#include <cmath>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
#include "Math.hpp"
|
|
||||||
#include "values/mrand.hpp"
|
|
||||||
|
|
||||||
#include <raymath.h>
|
|
||||||
|
|
||||||
Color ColorAddValue(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};
|
|
||||||
}
|
|
||||||
|
|
||||||
Color ColorAdd(Color c1, Color c2)
|
|
||||||
{
|
|
||||||
int r = std::clamp(c1.r + c2.r, 0, 255);
|
|
||||||
int g = std::clamp(c1.g + c2.g, 0, 255);
|
|
||||||
int b = std::clamp(c1.b + c2.b, 0, 255);
|
|
||||||
int a = std::clamp(c1.a + c2.a, 0, 255);
|
|
||||||
|
|
||||||
return {(unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a};
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle TextInSpace(Rectangle box, float textH, float textW, float margin, bool topOrBottom)
|
|
||||||
{
|
|
||||||
float br = box.width / box.height;
|
|
||||||
float tr = textW / textH;
|
|
||||||
|
|
||||||
Rectangle ret = {0, 0, 0, 0};
|
|
||||||
|
|
||||||
float hm = box.height * margin;
|
|
||||||
float wm = box.width * margin;
|
|
||||||
|
|
||||||
ret.height = box.height - hm;
|
|
||||||
ret.width = box.width - wm;
|
|
||||||
|
|
||||||
if (br < tr)
|
|
||||||
{
|
|
||||||
// bolj kvadrat izracunaj visino iz sirine
|
|
||||||
ret.height = ret.width / tr;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// bolj podolgovat izracunaj sirino iz visine
|
|
||||||
ret.width = ret.height * tr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (topOrBottom)
|
|
||||||
{
|
|
||||||
ret.y = box.y + hm;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret.y = box.y + box.height - hm - ret.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret.x = box.x + wm;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
@ -3,7 +3,6 @@
|
|||||||
#include "canvas/BackGround.hpp"
|
#include "canvas/BackGround.hpp"
|
||||||
#include "canvas/BackGroundColors.hpp"
|
#include "canvas/BackGroundColors.hpp"
|
||||||
#include "canvas/Circle.hpp"
|
#include "canvas/Circle.hpp"
|
||||||
#include "Math.hpp"
|
|
||||||
#include "stb_perlin.h"
|
#include "stb_perlin.h"
|
||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
@ -28,6 +27,25 @@ constexpr static float mounten2max = 0.90;
|
|||||||
constexpr static float mounten3min = 0.90f;
|
constexpr static float mounten3min = 0.90f;
|
||||||
constexpr static float mounten3max = 0.95f;
|
constexpr static float mounten3max = 0.95f;
|
||||||
|
|
||||||
|
Color ColorAddValue(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};
|
||||||
|
}
|
||||||
|
|
||||||
|
Color ColorAdd(Color c1, Color c2)
|
||||||
|
{
|
||||||
|
int r = std::clamp(c1.r + c2.r, 0, 255);
|
||||||
|
int g = std::clamp(c1.g + c2.g, 0, 255);
|
||||||
|
int b = std::clamp(c1.b + c2.b, 0, 255);
|
||||||
|
int a = std::clamp(c1.a + c2.a, 0, 255);
|
||||||
|
|
||||||
|
return {(unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a};
|
||||||
|
}
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
void BackGround::init(int canvasSize)
|
void BackGround::init(int canvasSize)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include "canvas/Circle.hpp"
|
#include "canvas/Circle.hpp"
|
||||||
#include "sunShader.hpp"
|
#include "sunShader.hpp"
|
||||||
|
|
||||||
#include "Math.hpp"
|
|
||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <rlgl.h>
|
#include <rlgl.h>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
#include "canvas/Tree.hpp"
|
#include "canvas/Tree.hpp"
|
||||||
#include "canvas/Circle.hpp"
|
#include "canvas/Circle.hpp"
|
||||||
#include "Math.hpp"
|
|
||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
#include <raymath.h>
|
#include <raymath.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user