Move files
BackGround, Canvas, Tree to dir canvas
This commit is contained in:
36
inc/canvas/BackGround.hpp
Normal file
36
inc/canvas/BackGround.hpp
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <vector>
|
||||
#include "raylib.h"
|
||||
|
||||
class BackGround
|
||||
{
|
||||
|
||||
public:
|
||||
BackGround() = default;
|
||||
~BackGround() = default;
|
||||
void init(int size);
|
||||
void newGen();
|
||||
|
||||
private:
|
||||
void starts();
|
||||
void moon();
|
||||
void mounten(size_t mountenSegments, float scale, int min, int max, Color color);
|
||||
|
||||
int size = 0;
|
||||
Texture2D texShapes = {1, 1, 1, 1, 7};
|
||||
|
||||
Color backGroundColor = {21, 34, 56, 255};
|
||||
|
||||
size_t numOfStarts = 150;
|
||||
Color starColor = WHITE;
|
||||
|
||||
Color moonColor = {240, 240, 190, 255};
|
||||
float minSizeOfMoon = 0.05f;
|
||||
float maxSizeOfMoon = 0.075f;
|
||||
float maxYPosOfMoon = 0.75f;
|
||||
|
||||
Color mountenColor = {28, 28, 38, 255};
|
||||
float mounten1 = 0.6875f;
|
||||
float mounten2 = 0.8125f;
|
||||
float mounten3 = 0.9125;
|
||||
float mounten4 = 0.975f;
|
||||
};
|
20
inc/canvas/Canvas.hpp
Normal file
20
inc/canvas/Canvas.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "raylib.h"
|
||||
#include "BackGround.hpp"
|
||||
#include "Tree.hpp"
|
||||
|
||||
class Canvas
|
||||
{
|
||||
|
||||
public:
|
||||
Canvas() = default;
|
||||
~Canvas() = default;
|
||||
void init(int size);
|
||||
void newGen();
|
||||
void draw(Rectangle dest, float rotation);
|
||||
void deinit();
|
||||
|
||||
private:
|
||||
BackGround backGround;
|
||||
Tree tree;
|
||||
RenderTexture2D target = {0};
|
||||
};
|
42
inc/canvas/Tree.hpp
Normal file
42
inc/canvas/Tree.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "raylib.h"
|
||||
|
||||
#define MAX_DEPTH 11
|
||||
|
||||
struct Branch
|
||||
{
|
||||
Color color;
|
||||
uint8_t numOfBranches;
|
||||
float lenghthRatio;
|
||||
};
|
||||
|
||||
struct DrawArgs
|
||||
{
|
||||
Vector2 start;
|
||||
float angleDeg;
|
||||
float lenghth;
|
||||
int dep;
|
||||
};
|
||||
|
||||
class Tree
|
||||
{
|
||||
|
||||
public:
|
||||
Tree() = default;
|
||||
~Tree() = default;
|
||||
void init(int size);
|
||||
void newGen();
|
||||
|
||||
private:
|
||||
int size = 0;
|
||||
Vector2 start = {0};
|
||||
std::vector<Branch> branches;
|
||||
std::list<DrawArgs> draw_calls;
|
||||
|
||||
void generateBranches();
|
||||
void drawTree();
|
||||
void drawBranch();
|
||||
Vector2 drawLine();
|
||||
};
|
Reference in New Issue
Block a user