treender/inc/Tree.hpp
2024-03-03 21:06:06 +01:00

43 lines
681 B
C++

#include "raylib.h";
#include <cstdint>
#include <vector>
#include <list>
#define MAX_DEPTH 11
struct branch
{
Color color;
uint8_t numOfBranches;
float lenghthRatio;
};
struct draw_args
{
Vector2 start;
float angleDeg;
float lenghth;
int dep;
};
class Tree
{
public:
Tree(int size);
~Tree();
void Draw(Rectangle dest);
void new_tree();
void generate_tree();
void draw_tree(draw_args first);
void draw_branch(draw_args arg);
Vector2 draw_line(Vector2 start, float angleDeg, float lenghth, int dep);
private:
int size = 0;
RenderTexture2D target = {0};
Vector2 start = {0};
std::vector<branch> tree;
std::list<draw_args> draw_calls;
};