From 513874d61cbdcd266cb52ae4a1dd1215a7c3eb65 Mon Sep 17 00:00:00 2001 From: Nikola Petrov Date: Thu, 18 Apr 2024 06:11:30 +0200 Subject: [PATCH] Add ratio for sun rings --- inc/canvas/BackGround.hpp | 9 +++++++- src/canvas/BackGround.cpp | 47 +++++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/inc/canvas/BackGround.hpp b/inc/canvas/BackGround.hpp index 4e81dba..aa61bf1 100644 --- a/inc/canvas/BackGround.hpp +++ b/inc/canvas/BackGround.hpp @@ -27,8 +27,15 @@ private: float minSizeOfMoon = 0.05f; float maxSizeOfMoon = 0.075f; float maxYPosOfMoon = 0.75f; + float bigRingRatio = 0.5f; + float smallRingRatio = 0.25f; + float bigRingBlend = 0.02f; + float smallRingBlend = 0.05f; - Color mountenColor = {28, 28, 38, 255}; + Color backMountenColor = {28, 28, 38, 255}; + Color frontMountenColor = {0, 0, 0, 255}; + float colorRatio1 = 0.3f; + float colorRatio2 = 0.5f; float mounten1 = 0.6875f; float mounten2 = 0.8125f; float mounten3 = 0.9125; diff --git a/src/canvas/BackGround.cpp b/src/canvas/BackGround.cpp index 23e451f..4b11386 100644 --- a/src/canvas/BackGround.cpp +++ b/src/canvas/BackGround.cpp @@ -17,9 +17,9 @@ void BackGround::newGen() ClearBackground(backGroundColor); starts(); moon(); - mounten(20, 0.3, (int)(mounten1 * size), (int)(mounten2 * size), mountenColor); - mounten(21, 0.3, (int)(mounten2 * size), (int)(mounten3 * size), ColorLerp(mountenColor, BLACK, 0.1f)); - mounten(23, 0.3, (int)(mounten3 * size), (int)(mounten4 * size), ColorLerp(mountenColor, BLACK, 0.3f)); + 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)); } void BackGround::starts() @@ -28,6 +28,8 @@ void BackGround::starts() rlBegin(RL_TRIANGLES); rlNormal3f(0.0f, 0.0f, 1.0f); + bool star = true; + for (size_t i = 1; i <= numOfStarts; i++) { int x = GetRandomValue(0, size); @@ -38,20 +40,25 @@ void BackGround::starts() Color color = ColorLerp(backGroundColor, starColor, alph); rlColor4ub(color.r, color.g, color.b, color.a); - - // topLeft - rlVertex2f(x, y); - // bottomLeft - rlVertex2f(x, y + weight); - // topRight - rlVertex2f(x + weight, y); - - // bottomRight - rlVertex2f(x + weight, y + weight); - // topRight - rlVertex2f(x + weight, y); - // bottomLeft - rlVertex2f(x, y + weight); + if (star) + { + // topLeft + rlVertex2f(x, y); + // bottomLeft + rlVertex2f(x, y + weight); + // topRight + rlVertex2f(x + weight, y); + } + else + { + // bottomRight + rlVertex2f(x + weight, y + weight); + // topRight + rlVertex2f(x + weight, y); + // bottomLeft + rlVertex2f(x, y + weight); + } + star = !star; } rlEnd(); rlSetTexture(0); @@ -62,9 +69,11 @@ void BackGround::moon() int xpos = GetRandomValue(100, size - 100); int ypos = GetRandomValue(100, (int)(maxYPosOfMoon * size)); int r = GetRandomValue((int)(minSizeOfMoon * size), (int)(maxSizeOfMoon * size)); + int ring1 = (float)r * bigRingRatio; + int ring2 = (float)r * smallRingRatio; - DrawCircle(xpos, ypos, r + 20, ColorLerp(backGroundColor, moonColor, 0.02f)); - DrawCircle(xpos, ypos, r + 10, ColorLerp(backGroundColor, moonColor, 0.05f)); + DrawCircle(xpos, ypos, r + ring1, ColorLerp(backGroundColor, moonColor, bigRingBlend)); + DrawCircle(xpos, ypos, r + ring2, ColorLerp(backGroundColor, moonColor, smallRingBlend)); DrawCircle(xpos, ypos, r, moonColor); }