Rainbow Recursion
Rainbow Recursion
#include <string>
#include <stdlib.h>
#include <windows.h>
HANDLE hOUTPUT = GetStdHandle(STD_OUTPUT_HANDLE);
using namespace std;
// recursion
int recursion(bool shifter, int n = 0, int number_for_rainbow = 0)
{
if (n < 1)
return 0;
if (number_for_rainbow >= 7)
number_for_rainbow *= 0;
number_for_rainbow++;
/*
if (color % 7 == 0)
{
violet("iteration", color);
}
else if (color % 6 == 0)
{
dark_blue("iteration", color);
}
else if (color % 5 == 0)
{
blue("iteration", color);
}
else if (color % 4 == 0)
{
green("iteration", color);
}
else if (color % 3 == 0)
{
yellow("iteration", color);
}
else if (color % 2 == 0)
{
orange("iteration", color);
}
else if (color % 1 == 0)
{
red("iteration", color);
cout << endl;
}
*/
if (number_for_rainbow == 7)
{
violet("iteration", color);
cout << endl;
}
else if (number_for_rainbow == 6)
{
dark_blue("iteration", color);
}
else if (number_for_rainbow == 5)
{
blue("iteration", color);
}
else if (number_for_rainbow == 4)
{
green("iteration", color);
}
else if (number_for_rainbow == 3)
{
yellow("iteration", color);
}
else if (number_for_rainbow == 2)
{
orange("iteration", color);
}
else if (number_for_rainbow == 1)
{
red("iteration", color);
}
if (for_switcher_operation % 60 == 0)
{
shifter = !shifter; // genial juggling with a shifter bool
}
if (shifter == true)
switcher_operation = 0.6;
else if (shifter == false)
switcher_operation = -0.6;
for_switcher_operation++;
/*
for (size_t i = 0; i < 10; i++)
{
if (for_switcher_operation == 60 * i)
shifter = !shifter; // genial juggling with a shifter bool
}
*/
/*
int thirty = 60;
for_switcher_operation++;
if (for_switcher_operation % thirty == 0)
switcher_operation = -0.3;
else if (for_switcher_operation % 2 * thirty == 0 || for_switcher_operation
== 1)
switcher_operation = 0.6;
*/
/*
if (different_speed < 30 && different_speed >= 0)
{
switcher_operation = 0.6;
}
if (different_speed > 30 && different_speed < 35)
{
switcher_operation = -0.3;
}
different_speed += switcher_operation;
*/
different_speed += switcher_operation;
int sleep_time = different_speed;
Sleep(sleep_time);
n -= 1;
return recursion(shifter, n, number_for_rainbow);
}
int main()
{
recursion(false, 700, 0);
SetConsoleTextAttribute(hOUTPUT, FOREGROUND_RED | FOREGROUND_GREEN |
FOREGROUND_BLUE);
cout << endl << "END" << endl << "return recursion = " << recursion(true) <<
endl;
}