add Color class for easy change

This commit is contained in:
Nikola Petrov
2024-05-02 20:50:45 +02:00
parent 513874d61c
commit eb4020a4ee
4 changed files with 39 additions and 14 deletions

View File

@@ -1,4 +1,5 @@
#include "canvas/BackGround.hpp"
#include "canvas/BackGroundColors.hpp"
#include "Math.hpp"
#include "raylib.h"
@@ -14,12 +15,13 @@ void BackGround::init(int size)
void BackGround::newGen()
{
ClearBackground(backGroundColor);
BackGroundColors::setColor();
ClearBackground(BackGroundColors::backGroundColor);
starts();
moon();
mounten(20, 0.3, (int)(mounten1 * size), (int)(mounten2 * size), backMountenColor);
mounten(21, 0.3, (int)(mounten2 * size), (int)(mounten3 * size), ColorLerp(backMountenColor, frontMountenColor, colorRatio1));
mounten(23, 0.3, (int)(mounten3 * size), (int)(mounten4 * size), ColorLerp(backMountenColor, frontMountenColor, colorRatio2));
mounten(20, 0.3, (int)(mounten1 * size), (int)(mounten2 * size), BackGroundColors::backMountenColor);
mounten(21, 0.3, (int)(mounten2 * size), (int)(mounten3 * size), ColorLerp(BackGroundColors::backMountenColor, BackGroundColors::frontMountenColor, colorRatio1));
mounten(23, 0.3, (int)(mounten3 * size), (int)(mounten4 * size), ColorLerp(BackGroundColors::backMountenColor, BackGroundColors::frontMountenColor, colorRatio2));
}
void BackGround::starts()
@@ -37,7 +39,7 @@ void BackGround::starts()
int weight = GetRandomValue(1, 3);
float alph = ((float)GetRandomValue(10, 200)) / 255.0f;
Color color = ColorLerp(backGroundColor, starColor, alph);
Color color = ColorLerp(BackGroundColors::backGroundColor, BackGroundColors::starColor, alph);
rlColor4ub(color.r, color.g, color.b, color.a);
if (star)
@@ -72,9 +74,9 @@ void BackGround::moon()
int ring1 = (float)r * bigRingRatio;
int ring2 = (float)r * smallRingRatio;
DrawCircle(xpos, ypos, r + ring1, ColorLerp(backGroundColor, moonColor, bigRingBlend));
DrawCircle(xpos, ypos, r + ring2, ColorLerp(backGroundColor, moonColor, smallRingBlend));
DrawCircle(xpos, ypos, r, moonColor);
DrawCircle(xpos, ypos, r + ring1, ColorLerp(BackGroundColors::backGroundColor, BackGroundColors::moonColor, bigRingBlend));
DrawCircle(xpos, ypos, r + ring2, ColorLerp(BackGroundColors::backGroundColor, BackGroundColors::moonColor, smallRingBlend));
DrawCircle(xpos, ypos, r, BackGroundColors::moonColor);
}
void BackGround::mounten(size_t mountenSegments, float scale, int min, int max, Color color)

View File

@@ -0,0 +1,16 @@
#include "canvas/BackGroundColors.hpp"
Color BackGroundColors::backGroundColor;
Color BackGroundColors::starColor;
Color BackGroundColors::moonColor;
Color BackGroundColors::backMountenColor;
Color BackGroundColors::frontMountenColor;
void BackGroundColors::setColor()
{
backGroundColor = {21, 34, 56, 255};
starColor = WHITE;
moonColor = {240, 240, 190, 255};
backMountenColor = {28, 28, 38, 255};
frontMountenColor = {0, 0, 0, 255};
}