package rainbowPackage;

//import javafx.scene.paint.Paint.*;
import javafx.scene.paint.Color;

public class ColorSlider //Basic Class For Variating Colors For RainbowSoftColor.java Class
{
	public double[] rgb = {0,0,0};
	public Color fxColor;
	public double colorBeingChecked = 0;//, ColorToBeChecked = 0;
	public int alpha = 0, red = 0, green = 0, blue = 0;
	//ColorValueFit colorValueFit = new ColorValueFit(0.);
	public ColorSlider()//1st Square DiagnosticsClass.java
	{
        rgb = new double[]{0,0,0};
        fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) );
	}
	public ColorSlider( Color FXColor )//2nd Square DiagnosticsClass.java
	{
		fxColor = FXColor;
        rgb = new double[] { fxColor.getRed() * 255, fxColor.getGreen() * 255, fxColor.getBlue() * 255 };
    }
	public ColorSlider( double[] RGB )//3rd Square DiagnosticsClass.java
	{
        rgb = RGB;
        fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) );
    }
	public Object ColorSliderFunction(double ColorInterval, double Loc, ColorSlider ColorBefore, ColorSlider ColorAfter)//4th Square DiagnosticsClass.java
	{
		for (int z = 0; z <= 2; z++)
			rgb[z] = ColorValueFitter( ( (ColorAfter.rgb[z] - ColorBefore.rgb[z]) * Loc/ColorInterval + ColorBefore.rgb[z] ) );
        fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) );
		return new ColorSlider( rgb );
	}
	public Object ColorSliderFunction(double ColorInterval, double Loc, double BrightnessMultiplyer, ColorSlider ColorBefore, ColorSlider ColorAfter)//5th Square DiagnosticsClass.java
	{
		if ( BrightnessMultiplyer <= 1 && BrightnessMultiplyer >= 0 )
			for (int z = 0; z <= 2; z++)
				rgb[z] = ColorValueFitter( ( ( (ColorAfter.rgb[z] - ColorBefore.rgb[z]) * Loc/ColorInterval + ColorBefore.rgb[z] ) * BrightnessMultiplyer) );
		else
			for (int z = 0; z <= 2; z++)
			{
				rgb[z] = Math.abs( ( ( (ColorAfter.rgb[z] - ColorBefore.rgb[z]) * Loc/ColorInterval + ColorBefore.rgb[z] ) ) );
				rgb[z] = ColorValueFitter( (255 - rgb[z]) / BrightnessMultiplyer + rgb[z] );
			}
        fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) );
		return new ColorSlider( rgb );
	}
	public Object ColorSliderFunction(double ColorInterval, double Loc, ColorSlider ColorBefore, ColorSlider ColorAfter, int Gradations)//6th Square DiagnosticsClass.java
	{
		for (int z = 0; z <= 2; z++)
			rgb[z] = ColorValueFitter( ( (ColorAfter.rgb[z] - ColorBefore.rgb[z]) * Math.floor( Loc/ColorInterval * ( Gradations + 2 ) ) / ( Gradations + 1 ) + ColorBefore.rgb[z] ) );
        fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) );
		return new ColorSlider( rgb );
	}
	public Object ColorSliderFunction(double ColorInterval, double Loc, double BrightnessMultiplyer, ColorSlider ColorBefore, ColorSlider ColorAfter, int Gradations)//7th Square DiagnosticsClass.java
	{
		if ( BrightnessMultiplyer <= 1 && BrightnessMultiplyer >= 0 )
			for (int z = 0; z <= 2; z++)
				rgb[z] = ColorValueFitter( ( (ColorAfter.rgb[z] - ColorBefore.rgb[z]) * Math.floor( Loc/ColorInterval * ( Gradations + 2 ) ) / ( Gradations + 1 ) + ColorBefore.rgb[z] * BrightnessMultiplyer ) );
		else
			for (int z = 0; z <= 2; z++)
			{
				rgb[z] = Math.abs( ( (ColorAfter.rgb[z] - ColorBefore.rgb[z]) * Math.floor( Loc/ColorInterval * ( Gradations + 2 ) ) / ( Gradations + 1 ) + ColorBefore.rgb[z] ) );
				rgb[z] = ( (255 - rgb[z]) / BrightnessMultiplyer + rgb[z] );
			}
        fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) );
		return new ColorSlider( rgb );
	}
	public Color ToFXColor ()//8th Square DiagnosticsClass.java
	{
        fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) );
        return fxColor;
	}
	public Color ToFXColor ( double[] RGB )//9th Square DiagnosticsClass.java
	{
		rgb = RGB;
        fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) );
        return fxColor;
	}
	/*public int ToARGBcolorNum()
	{
		alpha = (alpha << 24) & 0xFF000000;
	    red = (red << 16) & 0x00FF0000; //Shift red 16-bits and mask out other stuff
	    green = (green << 8) & 0x0000FF00; //Shift Green 8-bits and mask out other stuff
	    blue = blue & 0x000000FF; //Mask out anything not blue.

	    return 0x00000000 alpha | red | green | blue; //0xFF000000 for 100% Alpha. Bitwise OR everything together.
	}
	public int ToARGBcolorNum ()//8th Square DiagnosticsClass.java
	{
        fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) );
        return (int)( 255 * 16777216 + rgb[0] * 65536 + rgb[1] * 256 + rgb[2] );
	}
	public int ToARGBcolorNum ( double[] RGB )//9th Square DiagnosticsClass.java
	{
		rgb = RGB;
        fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) );
        return (int)( 255 * 16777216 + rgb[0] * 65536 + rgb[1] * 256 + rgb[2] );
	}
	public int ToARGBcolorNum ( Color FXColor )//9th Square DiagnosticsClass.java
	{
		rgb = new double[] { FXColor.getRed() * 255, FXColor.getGreen() * 255, FXColor.getBlue() * 255 };
        fxColor = FXColor;
        return (int)( 255 * 16777216 + rgb[0] * 65536 + rgb[1] * 256 + rgb[2] );
	}*/
	//tempFXColor = tempFXColor.rgb((int)color.rgb[0] , Math.abs( (int)color.rgb[1] ), (int)color.rgb[2]).invert();
	public Boolean ColorTooSimilarFunction(int Color1, int Color2)//10th Square DiagnosticsClass.java
	{
		Boolean TooSimilar = false;
		int color1A = (Color1 >> 24) & 0xff;
	    int color1R = (Color1 >> 16) & 0xff;
	    int color1G = (Color1 >> 8) & 0xff;
	    int color1B = (Color1) & 0xff;
	    int color2A = (Color2 >> 24) & 0xff;
	    int color2R = (Color2 >> 16) & 0xff;
	    int color2G = (Color2 >> 8) & 0xff;
	    int color2B = (Color2) & 0xff;
		/*
		int Color1A = Color1 / 16777216;
		int Color1R = ( Color1 - Color1A * 16777216 ) / 65536;
		int Color1G = ( Color1 - Color1A * 16777216 - Color1R * 65536 ) / 256;
		int Color1B = ( Color1 - Color1A * 16777216 - Color1R * 65536 - Color1G * 256);
		int Color2A = Color2 / 16777216;
		int Color2R = ( Color2 - Color2A * 16777216 ) / 65536;
		int Color2G = ( Color2 - Color2A * 16777216 - Color2R * 65536 ) / 256;
		int Color2B = ( Color2 - Color2A * 16777216 - Color2R * 65536 - Color2G * 256);// */
		int colorDifference = Math.abs(color1R - color2R) + Math.abs(color1G - color2G) + Math.abs(color1B - color2B);
		if ( colorDifference <= 164 )
			TooSimilar = true;
		else
			TooSimilar = false;
		//System.out.println("colorDifference: " + colorDifference);
		//System.out.println(TooSimilar);
		return TooSimilar;
	}
	public Boolean ColorTooSimilarFunction(Color Color1, Color Color2)//4th Square DiagnosticsClass.java
	{
		Boolean TooSimilar = false;
		int colorDifference = (int)(Math.abs(Math.abs(Color1.getRed()) - Math.abs(Color2.getRed())) + Math.abs(Math.abs(Color1.getGreen()) - Math.abs(Color2.getGreen())) + Math.abs(Math.abs(Color1.getBlue()) - Math.abs(Color2.getBlue())));
		if ( colorDifference <= 164 )//200 )
			TooSimilar = true;
		else
			TooSimilar = false;
		//System.out.println("colorDifference: " + colorDifference);
		//System.out.println(TooSimilar);
		return TooSimilar;
	}
	public Boolean ColorTooSimilarFunction(ColorSlider Color1, ColorSlider Color2)//11th Square DiagnosticsClass.java
	{
		Boolean TooSimilar = false;
		int colorDifference = (int)( Math.abs(Color1.rgb[0] - Color2.rgb[0]) + Math.abs(Color1.rgb[1] - Color2.rgb[1]) + Math.abs(Color1.rgb[2] - Color2.rgb[2]) );
		if ( colorDifference <= 164 )
			TooSimilar = true;
		else
			TooSimilar = false;
		//System.out.println("colorDifference: " + colorDifference);
		//System.out.println(TooSimilar);
		return TooSimilar;
	}
	public Boolean ColorTooSimilarFunction(int Color1, int Color2, double ColorDifference)//3rd Square DiagnosticsClass.java
	{
		Boolean TooSimilar = false;
	    int color1A = (Color1 >> 24) & 0xff;
	    int color1R = (Color1 >> 16) & 0xff;
	    int color1G = (Color1 >> 8) & 0xff;
	    int color1B = (Color1) & 0xff;
	    int color2A = (Color2 >> 24) & 0xff;
	    int color2R = (Color2 >> 16) & 0xff;
	    int color2G = (Color2 >> 8) & 0xff;
	    int color2B = (Color2) & 0xff;
		int colorDifference = Math.abs(Math.abs(color1R) - Math.abs(color2R)) + Math.abs(Math.abs(color1G) - Math.abs(color2G)) + Math.abs(Math.abs(color1B) - Math.abs(color2B));
		if ( colorDifference <= ColorDifference )//200 )
			TooSimilar = true;
		else
			TooSimilar = false;
		//System.out.println("colorDifference: " + colorDifference);
		//System.out.println(TooSimilar);
		return TooSimilar;
	}
	public Boolean ColorTooSimilarFunction(Color Color1, Color Color2, double ColorDifference)//4th Square DiagnosticsClass.java
	{
		Boolean TooSimilar = false;
		int colorDifference = (int)(Math.abs(Math.abs(Color1.getRed()) - Math.abs(Color2.getRed())) + Math.abs(Math.abs(Color1.getGreen()) - Math.abs(Color2.getGreen())) + Math.abs(Math.abs(Color1.getBlue()) - Math.abs(Color2.getBlue())));
		if ( colorDifference <= ColorDifference )//200 )
			TooSimilar = true;
		else
			TooSimilar = false;
		//System.out.println("colorDifference: " + colorDifference);
		//System.out.println(TooSimilar);
		return TooSimilar;
	}
	public Boolean ColorTooSimilarFunction(ColorSlider Color1, ColorSlider Color2, double ColorDifference)//11th Square DiagnosticsClass.java
	{
		Boolean TooSimilar = false;
		int colorDifference = (int)( Math.abs(Color1.rgb[0] - Color2.rgb[0]) + Math.abs(Color1.rgb[1] - Color2.rgb[1]) + Math.abs(Color1.rgb[2] - Color2.rgb[2]) );
		if ( colorDifference <= ColorDifference )
			TooSimilar = true;
		else
			TooSimilar = false;
		//System.out.println("colorDifference: " + colorDifference);
		//System.out.println(TooSimilar);
		return TooSimilar;
	}
	public double ColorValueFitter ( double ColorToBeChecked )//12th Square DiagnosticsClass.java
	{
		colorBeingChecked = Math.abs(ColorToBeChecked);
		while ( colorBeingChecked > 255)
			colorBeingChecked = colorBeingChecked - 255;
		return colorBeingChecked;
	}
	public void set(double[] RGB) { rgb = RGB; fxColor = fxColor.rgb( (int)(ColorValueFitter(rgb[0])), (int)(ColorValueFitter(rgb[1])), (int)(ColorValueFitter(rgb[2])) ); }//13th Square DiagnosticsClass.java
	public void set(Color FXColor) { fxColor = FXColor; rgb = new double[] { ColorValueFitter(fxColor.getRed() * 255), ColorValueFitter(fxColor.getGreen() * 255), ColorValueFitter(fxColor.getBlue() * 255) }; }//14th Square DiagnosticsClass.java
    public Object get() { return rgb; }//15th Square DiagnosticsClass.java
    //public Object get() { return fxColor; }
}//*/


/*public class Color(double R, double G, double B)  Color
{
	rgb[0] = R;
	rgb[1] = G;
	rgb[2] = B;
	//return rgb;
}*/
