add Color class for easy change
This commit is contained in:
		| @@ -18,12 +18,8 @@ private: | ||||
|   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; | ||||
| @@ -32,8 +28,6 @@ private: | ||||
|   float bigRingBlend = 0.02f; | ||||
|   float smallRingBlend = 0.05f; | ||||
|  | ||||
|   Color backMountenColor = {28, 28, 38, 255}; | ||||
|   Color frontMountenColor = {0, 0, 0, 255}; | ||||
|   float colorRatio1 = 0.3f; | ||||
|   float colorRatio2 = 0.5f; | ||||
|   float mounten1 = 0.6875f; | ||||
|   | ||||
							
								
								
									
										13
									
								
								inc/canvas/BackGroundColors.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								inc/canvas/BackGroundColors.hpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| #include "raylib.h" | ||||
|  | ||||
| class BackGroundColors | ||||
| { | ||||
| private: | ||||
| public: | ||||
|   static void setColor(); | ||||
|   static Color backGroundColor; | ||||
|   static Color starColor; | ||||
|   static Color moonColor; | ||||
|   static Color backMountenColor; | ||||
|   static Color frontMountenColor; | ||||
| }; | ||||
| @@ -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) | ||||
|   | ||||
							
								
								
									
										16
									
								
								src/canvas/BackGroundColors.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/canvas/BackGroundColors.cpp
									
									
									
									
									
										Normal 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}; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Nikola Petrov
					Nikola Petrov