Exemplo n.º 1
0
RGBColor::RGBColor(const char* hexColor)
{
    if (strlen(hexColor) == 7) {
        QString str1, str2, str3;
        
        str1.append(hexColor[1]);
        str1.append(hexColor[2]);
        str2.append(hexColor[3]);
        str2.append(hexColor[4]);
        str3.append(hexColor[5]);
        str3.append(hexColor[6]);
        
        bool ok;
        
            r = str1.toUInt(&ok,16);
        if (!ok)
            qDebug() << "Error with r component";
            g = str2.toUInt(&ok,16);
        if (!ok)
            qDebug() << "Error with g component";
            b = str3.toUInt(&ok,16);
        if (!ok)
            qDebug() << "Error with b component";
        qDebug() << r << g << b;
        setNewColor(r, g, b);
    }else{
        
        qDebug() << "Not the right color lenght, apparently";
        return;
    }
}
Exemplo n.º 2
0
//Calculs necessessaire pour la graduation
void RGBColor::calculateColor(int operation,RGBColor &color1, RGBColor &color2, int argument)
{
	switch (operation)
	{
	case 0:
		setNewColor((color2.r - color1.r) / (argument-1),
					(color2.g - color1.g) / (argument-1),
					(color2.b - color1.b) / (argument-1));
		break;
	case 1:
		setNewColor((color1.r + (color2.r*argument)),
					(color1.g + (color2.g*argument)),
					(color1.b + (color2.b*argument)));
		break;
	default:
		break;
	}
}
Exemplo n.º 3
0
//Calculs necessessaire pour la graduation en sigmoid
void RGBColor::calculateColor(vector<double> RedOpp, vector<double> GreenOpp, vector<double> BlueOpp, int argument)
{
	// 0 = Yi
	// 1 = Yf
	// 2 = a
	// 3 = b
	double Red = (RedOpp[0] - RedOpp[1]) / (1 + exp(RedOpp[2] * (argument - RedOpp[3]))) + RedOpp[1];
	double Green = (GreenOpp[0] - GreenOpp[1]) / (1 + exp(GreenOpp[2] * (argument - GreenOpp[3]))) + GreenOpp[1];
	double Blue = (BlueOpp[0] - BlueOpp[1]) / (1 + exp(BlueOpp[2] * (argument - BlueOpp[3]))) + BlueOpp[1];

	setNewColor(((Red > 255) ? 255 : ((Red < 0) ? 0 : Red)),
				((Green > 255) ? 255 : ((Green < 0) ? 0 : Green)),
				((Blue > 255) ? 255 : ((Blue < 0) ? 0 : Blue)));

	/*if (y > 255)
		y = 255;
	if (y < 0)
		y = 0;¸*/
}
Exemplo n.º 4
0
// Copy Constuctor for Rose.
// Sets up a new Flower, then copies the Image, originalColor and newColor to the new carnation object
// Returns: Nothing
// Parameters: Rose&
Rose::Rose(Rose & source) {
	Flower();
	*flowerImage = *(source.flowerImage);
	originColor = getRoseOriginal();
	setNewColor(source.getNewColor());	
}
Exemplo n.º 5
0
RGBColor::RGBColor(double red, double green, double blue)
{
	setNewColor(red,green,blue);
}
Exemplo n.º 6
0
RGBColor::RGBColor()
{
	setNewColor(0,0,0);
}