Example #1
0
void EffectsGenerator::gradientSigmoidTransition(int transitionSize, std::string &os)
{
	RGBColor tempColor;

	for (int j = 0; j < (int)colors.size() - 1; j++)
	{
		vector<double> RedOperations = SigmoidCalculator(0, transitionSize, colors[j].getR(), colors[j + 1].getR());
		vector<double> GreenOperations = SigmoidCalculator(0, transitionSize, colors[j].getG(), colors[j + 1].getG());
		vector<double> BlueOperations = SigmoidCalculator(0, transitionSize, colors[j].getB(), colors[j + 1].getB());

		for (int i = 0; i < transitionSize; i++)
		{
			tempColor.calculateColor(RedOperations,GreenOperations,BlueOperations,i);

			//Envoyer les valeurs aux leds, ajouter un delais ou changer le transitionSize
            os += to_string(tempColor.getR()) + " "
				+ to_string(tempColor.getG()) + " "
				+ to_string(tempColor.getB()) + " ";
			//A remplacer par:
			//sendColorToServer(tempColor.getR(),tempColor.getG(),tempColor.getB())
		}

	}

}
Example #2
0
HSVColor::HSVColor(RGBColor color) {
	float r = color.getR();
	float g = color.getG();
	float b = color.getB();
	float min, max;
	min = getMin(r, getMin(g, b));
	max = getMax(r, getMax(g, b));
	if (min == max) 
		h = 0;
	else if (max == r && g >= b) 
		h = 60.0f*((g-b)/(max-min)) + 0;
	else if (max == r && g <  b) 
		h = 60.0f*((g-b)/(max-min)) + 360;
	else if (max == g) 
		h = 60.0f*((b-r)/(max-min)) + 120;
	else if (max == b) 
		h = 60.0f*((r-g)/(max-min)) + 240;

	if (max == 0) s = 0;
	else s = 1 - (min/max);

	v = max;
};