package Sonnet;

import java.awt.*;
import java.awt.image.*;
import java.awt.event.ActionEvent;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.lang.Object;
import java.io.InputStream;
import java.io.File;
import javax.imageio.ImageIO;//Keep For .png Image Creation
import java.io.IOException;
import java.nio.ByteBuffer;

import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.canvas.*;
import javafx.scene.layout.VBox;


import javafx.beans.*;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;

import Sonnet.ColorSlider;
import javafx.scene.paint.Color;

import javax.swing.JFileChooser;
//import javax.swing.JFrame;

import org.jcodec.api.awt.SequenceEncoder;

import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.canvas.*;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import jdk.nashorn.internal.runtime.Context;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelFormat;
import javafx.scene.image.PixelReader;
import javafx.scene.image.PixelWriter;
//import javafx.scene.paint.Color;
import javafx.scene.image.WritableImage;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.effect.DropShadow;
//import javafx.scene.*;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.control.Label;
import javax.swing.*;
import javax.swing.SwingConstants;
import javax.swing.JFrame.*;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JFileChooser;
import org.jcodec.api.awt.SequenceEncoder;//Keep For .mp4 Video Creation

/**
 * Tip 1: A canvas resizing itself to the size of
 *        the parent pane.
 */
public class Sonnet extends Application
{
	static int initialScreenSizeX = 1920, initialScreenSizeY = 1080;//1920x1080//3840, 2160//1440, 900 //3858, 2200//862
	static Dimension Dim = new Dimension(initialScreenSizeX, initialScreenSizeY), DimCheck = new Dimension(initialScreenSizeX, initialScreenSizeY), HalfedDim = new Dimension( Math.round( ( Dim.width + 1 ) / 2 - 1 ), Math.round( ( Dim.height - 37 ) / 2 - 1 ) ), DimLabel = new Dimension(1,1);
	static Group root = new Group();
	static Stage primaryStage;
	static StackPane stackPane = new StackPane();//static JFrame f = new JFrame("Sonnet");
	static Scene scene = new Scene(stackPane, 1920, 1080);
	//static Canvas canvas = new Canvas();
	static ImageView imageView = new ImageView();
	static VBox vBox = new VBox();
	static BufferedImage I = new BufferedImage(Dim.width, Dim.height, BufferedImage.TYPE_INT_RGB);
	static WritableRaster wr = I.getRaster();
	static JFileChooser fileChooser = new JFileChooser();
	static String path = "C:\\TestVideo.mp4", text = "Sky.Netarianism";//"C:\\TestImage.png"//"C:\\TestVideo.mp4"//"C:\\TEMP_Sonnet.mp4";
	static File selectedFile = new File (path);
	static boolean doneWritingFirstImage = false;
	static SequenceEncoder enc;// = new SequenceEncoder(selectedFile);
	//static SequenceEncoder enc = new SequenceEncoder(selectedFile);
	static int borderSizeX = Dim.width/12, borderSizeY = Dim.height/6;
	static int choice = 0;//0 is SkyNet Pyramid, 1 is Full Spectral Rainbow, 2 is Y and Sonnet
	static final int numberOfColorsInTheRainbow = 15;//asdf Always Worry About This!
	static final ColorSlider black = new ColorSlider( new double[]{0,0,0} );
	static final ColorSlider white = new ColorSlider( new double[]{255,255,255} );
	static final ColorSlider skyblue = new ColorSlider( new double[]{134,206,249} );
	static final ColorSlider pink = new ColorSlider( new double[]{255,64,143} );
	static final ColorSlider blue = new ColorSlider( new double[]{0,0,192} );
	static final ColorSlider red = new ColorSlider( new double[]{193,0,0} );
	static final ColorSlider purple = new ColorSlider( new double[]{122,0,178} );
	static final ColorSlider orange = new ColorSlider( new double[]{255,134,0} );
	static final ColorSlider green = new ColorSlider( new double[]{0,133,50} );
	static final ColorSlider yellow = new ColorSlider( new double[]{246,252,15} );
	static final ColorSlider teal = new ColorSlider( new double[]{3,224,149} );
	static final ColorSlider bronze = new ColorSlider( new double[]{152,123,46} );
	static final ColorSlider silver = new ColorSlider( new double[]{193,192,192} );
	static final ColorSlider gold = new ColorSlider( new double[]{205,191,44} );
	static final ColorSlider lime = new ColorSlider( new double[]{126,193,33} );
	static final ColorSlider brown = new ColorSlider( new double[]{131,103,71} );

	//From http://www.programcreek.com/java-api-examples/index.php?api=javafx.scene.image.WritableImage
	/**
	 * Visualize the map.
	 * 
	 * @param Maximum
	 *            color
	 * @param winner
	 *            Winners array
	 */
	/*public void visualize(int max, int[][] winner) {
		// Randomly assign colors for visualization:
		Random r = new Random();
		int[] cols = new int[max + 1];
		for (int i = 1; i < cols.length; i++) {
			cols[i] = r.nextInt(0x1000000) | 0xFF000000;
		}
		try {
			WritableImage writableImage = new WritableImage(viewport.width,
					viewport.height);
			PixelWriter writer = writableImage.getPixelWriter();
			for (int y = 0; y < viewport.height; y++) {
				// Note: visualization is drawn upside down.
				int[] row = winner[viewport.height - 1 - y];
				for (int x = 0; x < viewport.width; x++) {
					writer.setArgb(x, y, cols[row[x]]);
				}
			}
			ImageIO.write(SwingFXUtils.fromFXImage(writableImage, null), "png",
					imfile);
		} catch (IOException e) {
			LOG.error("IO error writing visualization.", e);
		}
	}//*/
	
	
	
	/*package ripper.util;

	import javafx.application.Application;
	import javafx.geometry.Rectangle2D;
	import javafx.scene.Scene;
	import javafx.scene.layout.VBox;
	import javafx.scene.text.*;
	import javafx.stage.Screen;
	import javafx.stage.Stage;
	import javafx.scene.layout.*;
	import javafx.scene.paint.Color;
	import javafx.scene.shape.*;//*/

	/*public class ExampleFX extends Application
	{
		@Override
		public void start(Stage stage)
		{
			//test_1(stage);
			//test_2(stage);
			//test_4(stage);
			test_3(stage);
		}// */


		//http://www.tutorialized.com/tutorial/JavaFX-2-Full-Screen-Scene/76585
		/*
		static void test_4(Stage primaryStage)
		{
			primaryStage.setTitle("TilePane");

			// This is how you know how much screen you can write to.
			Screen screen = Screen.getPrimary();
			Rectangle2D bounds = screen.getVisualBounds();
			System.out.println(bounds);

			// This acts just like a canvas.
			Pane canvas = new Pane();
			canvas.setStyle("-fx-background-color: black;");
			canvas.setPrefSize(200, 200);
			Circle circle = new Circle(50, Color.BLUE);
			circle.relocate(20, 20);
			Rectangle rectangle = new Rectangle(100, 100, Color.RED);
			rectangle.relocate(70, 70);
			canvas.getChildren().addAll(circle, rectangle);

			// Adding canvas to the Scene
			Scene scene = new Scene(canvas);
			primaryStage.setScene(scene);
			// Set full screen
			primaryStage.setFullScreen(true);
			primaryStage.show();
		}

		static void test_3(Stage primaryStage)
		{
			primaryStage.setTitle("TilePane");

			// Adding StackPane
			/*
			StackPane pane = new StackPane();
			Pane sp = new Pane();
			Text txt = new Text("This is a full screen JavaFX 2 Scene...");
			txt.setFont(Font.font(null, FontWeight.BOLD, 72));
			txt.setFill(Color.RED);
			sp.getChildren().add(txt);
			*/
/*//Through Here
			Pane pane = new Pane();
			pane.setStyle("-fx-background-color: black;");
			pane.setPrefSize(200, 200);
			Circle circle = new Circle(50, Color.BLUE);
			circle.relocate(20, 20);
			Rectangle rectangle = new Rectangle(100, 100, Color.RED);
			rectangle.relocate(70, 70);
			pane.getChildren().addAll(circle, rectangle);

			// Adding StackPane to the Scene
			Scene scene = new Scene(pane);
			primaryStage.setScene(scene);
			// Set full screen
			primaryStage.setFullScreen(true);
			primaryStage.show();
		}// */
		
// From Dad's ExampleFX:
		/*
		static void test_2(Stage stage)
		{
			// http://stackoverflow.com/questions/31426912/how-to-make-window-fullscreen-maximized-in-scene-builder
			Screen screen = Screen.getPrimary();
			Rectangle2D bounds = screen.getVisualBounds();
			stage.setX(bounds.getMinX());
			stage.setY(bounds.getMinY());
			stage.setWidth(bounds.getWidth());
			stage.setHeight(bounds.getHeight());

			// http://www.java2s.com/Code/Java/JavaFX/Fullscreenstage.htm
			Text text = new Text("!");
			text.setFont(new Font(40));
			VBox box = new VBox();
			box.getChildren().add(text);
			final Scene scene = new Scene(box, 300, 250);
			scene.setFill(null);
			stage.setScene(scene);
			stage.show();

			stage.setFullScreen(true);
		}

		// http://www.java2s.com/Code/Java/JavaFX/Fullscreenstage.htm
		static void test_1(Stage stage)
		{
			Text text = new Text("!");
			text.setFont(new Font(40));
			VBox box = new VBox();
			box.getChildren().add(text);
			final Scene scene = new Scene(box, 300, 250);
			scene.setFill(null);
			stage.setScene(scene);
			stage.show();

			stage.setFullScreen(true);
		}

		public static void main(String[] args)
		{
			launch(args);
		}
	}
	//*/
	
	
	
	
	
	
	
	
	@Override
	public void start(Stage primaryStage)
	{
		Image image = new Image("http://skynetarianism.net/Pictures/KnightsOfTheSciMagOrder.png");
		ImageView imageView = new ImageView();
        imageView.setImage(image);
		// Display image on screen		StackPane root = new StackPane();
		/*root.getChildren().add(imageView);
		Scene scene = new Scene(root, 914, 875);
		primaryStage.setTitle("Sonnet");
		primaryStage.setScene(scene);
		primaryStage.setResizable(true);
		primaryStage.setMaximized(true);*/
		primaryStage.setMaximized(true);
		//PixelReader pr = image.getPixelReader();
		WritableImage wi = new WritableImage(
				(int)primaryStage.getWidth(),
				(int)primaryStage.getHeight());
		PixelWriter pw = wi.getPixelWriter();

		

		Dim.width = (int)primaryStage.getWidth();
		Dim.height = (int)primaryStage.getHeight();
		System.out.println( Dim );

		int x = 0, y = 0, xMinusxSlider = 0, yMinusxSlider = 0, cxMx = 0, ySlider = 0, yMinusySlider = 0, cyMy = 0;//cxMx Corrected xMinusSlider for determining color
		ColorSlider color = new ColorSlider( new double[]{0,0,0} ), testColor = new ColorSlider( new double[]{0,0,0} );
		int tempColor = 0;
		int tempBlue = 0;
		int tempGreen = 0;
		int tempRed = 0;
		int [] background = {255, 255, 255};
		double colorInterval = 0, a = 0, b = 0, xSlider = 0, xSliderInitial = 0, xSliderFactor = 10, xSliderBackAndFourth = 1;//Dim.width / ( numberOfColorsInTheRainbow - 1 );
		int cx = Math.round( (Dim.width + 1  ) / 2 - 1 );//Uncomment For Circular Rainbow
		int cy = Math.round( (Dim.height - 60 + 1 ) / 2 - 1 );//Uncomment For Circular Rainbow
		double xSliderZoomFactor = 0.1;
		double totalAngleUnits = 0;//Uncomment For Circular Rainbow
		//double spectralBrightnessMultiplyer = 1/2;
		boolean TrispectralRainbow = false;
		//Dimension DimLast = Dim;
		//Thread.sleep(4000);
		while (choice != 4)
		{
			if (choice == 0)
			{

				System.out.println( Dim );
				//Dim = f.getSize();//Dim = f.getContentPane().getSize();
				//f.setPreferredSize(Dim);//Comment Out For 4K UHD
				/*HalfedDim.width = Math.round( ( Dim.width + 1 ) / 2 - 9 );//For Fractal Use No: - 1 At The Other End Otherwise No
					HalfedDim.height = Math.round( ( Dim.height - 37 ) / 2 - 1 );//For Fractal Use No: - 1 At The Other End Otherwise No
				 */
				HalfedDim.width = Math.round( Dim.width / 2 );
				HalfedDim.height = Math.round( Dim.height / 2 );
				//I = new BufferedImage(HalfedDim.width * 2, HalfedDim.height * 2, BufferedImage.TYPE_INT_RGB);
				//DimCheck = Dim;
				//cy = Math.round( (Dim.height + 1 ) / 2 - 1 );//Use Only For Circular Rainbow When Not Moving
				Label label = new Label("My label");
				//Font font = new Font("Techno Hideo", Font.PLAIN, 10);
				colorInterval = Dim.width / ( numberOfColorsInTheRainbow - 1 );//Use For Noncircular Rainbow And Fractal
				if (TrispectralRainbow == true)
					colorInterval = colorInterval / 3;//For Trispectral Rainbow.
				double colorDisplacement = 0;//For Rainbow Disk And 0 Rainbow Clock
				double radialDistance = Math.pow(Math.pow(HalfedDim.width + 1, 2) + Math.pow(HalfedDim.height + 1, 2), 0.5);//For Clock And Rainbow Spiral No Whole Thing / 12 That Is For Fractal.
				double radialVariableDistance = radialDistance;
				double fullAngle = Math.PI * radialDistance;//For Hypnosis Spiral 2 * Math.PI * radialDistance
				double angle = 0;
				double radius = radialVariableDistance * 14.4 + colorDisplacement + angle;
				double interval = fullAngle / 10 / 111;//Last Division Determines The Frame Rate
				//JLabel label = new JLabel("My label");
				//Font font = new Font("Techno Hideo", Font.PLAIN, 10);
				int textWidth = 0;
				int xBlankSize = 0;
				int yTextSize = 0;
				double colorInterval2 = 100;
				xSlider = (int)Math.round(colorDisplacement) - 2 * interval;//For JCodec
				xSliderInitial = xSlider;
				while (xSlider < fullAngle / 10)//To Make Full Video !!!!USE ME!!!!:while (xSlider < fullAngle) //For JCodec
					//Without JCodec: for ( xSlider = (int)Math.round(colorDisplacement); xSlider < fullAngle; xSlider++)// For Fractal: (xSlider = 1 + (int)Math.round(colorDisplacement); xSlider <= 480; xSlider++) Or xSlider = xSlider + 0.00025, For Spirals xSlider < fullAngle For Fade-ins And Fade-outs xSlider <= 255 To Different Colors< For Rainbow Clock, xSlider = (int)Math.round(colorDisplacement); For Rings -144 Use cy And < HalfedDim.height Instead of Dim.height For Circular Rainbow Use Dim.width < For Rainbow Slider And Fractal //Start At -144 For Videos And Pictures
				{//0.175979734764 * 
					if (xSliderInitial == xSlider)
					{
						radialDistance = Math.pow(Math.pow(HalfedDim.width + 1, 2) + Math.pow(HalfedDim.height + 1, 2), 0.5);//For Clock And Rainbow Spiral No Whole Thing / 12 That Is For Fractal.
						radialVariableDistance = radialDistance;
						fullAngle = Math.PI * radialDistance;//For Hypnosis Spiral 2 * Math.PI * radialDistance
						angle = 0;
						radius = radialVariableDistance * 14.4 + colorDisplacement + angle;
						interval = fullAngle / 10 / 111;//Last Division Determines The Frame Rate

					}
					HalfedDim.width = Math.round( Dim.width / 2 );
					HalfedDim.height = Math.round( Dim.height / 2 );
					background = new int[Dim.width * Dim.height * 3];//background = new int[(HalfedDim.width * 2 + 1) * (HalfedDim.height * 2) * 3]//Use To Fix Left Side Raster Mess Up
					radialDistance = Math.pow(Math.pow(HalfedDim.width + 1, 2) + Math.pow(HalfedDim.height + 1, 2), 0.5);//For Clock And Rainbow Spiral
					colorInterval = fullAngle / ( numberOfColorsInTheRainbow - 1 );//For Rainbow Clock And Spiral
					colorDisplacement = 0;//For Rainbow Disk
					for (x = 0; x < Dim.width; x++)//x < HalfedDim.width * 2//For old Background Raster ( HalfedDim.width * 2 )// For Fractals And Rainbow Sliders And ??? ///To Test Moving Rainbow From Left To Right
					{
						for (y = 0; y < Dim.height; y++)//y < HalfedDim.height * 2//For old Background Raster ( HalfedDim.height * 2 )//Comment Out Here For NonFractals
						{
							radialVariableDistance = Math.pow(Math.pow(x - HalfedDim.width + 1, 2) + Math.pow( y - HalfedDim.height + 1, 2), 0.5);//Comment Out For  Ghetto Many Rainbow Clocks 

							if ( y - HalfedDim.height + 1 != 0) //y - HalfedDim.height + 1 < -tolerance || y - HalfedDim.height + 1 > tolerance )// OLD: ( y - HalfedDim.height + 1) != 0 && y != 0 //Use For Old Infinite Number Theorem Down
								angle = Math.atan2( (x - HalfedDim.width + 1) , (y - HalfedDim.height + 1 ) );
							else
								angle = Math.atan2( (x - HalfedDim.width + 1), 0.0002 );
							//	angle = Math.atan( x - HalfedDim.width + 1 / ( y - HalfedDim.height + 1 ) );//WON'T WORK FOR NO GOOD REASON
							//else//WON'T WORK FOR NO GOOD REASON
							//	angle = Math.atan( x - HalfedDim.width + 1 / .0002 );//WON'T WORK FOR NO GOOD REASONRenderedImage
							//	angle = Math.atan2( x - HalfedDim.width + 1, tolerance ); //Adjust The Small Number For Mostly Black Screen

							a = ( angle * /*Math.cos( angle ) * Math.sin( angle ) * Math.pow(radialVariableDistance, 1)*/ Math.tan( angle ) + Math.PI )  * radialDistance / 4.46783504 - xSlider;//For Infinite Number Theorem Good a = ( angle * /*Math.cos( angle ) * Math.sin( angle ) * Math.pow(radialVariableDistance, 1)*/ Math.tan( angle ) + Math.PI )  * radialDistance / 4.46783504 - xSlider;  //a = ( angle /*Math.cos( angle ) * Math.sin( angle ) * Math.pow(radialVariableDistance, 1)*/ Math.tan( angle ) + Math.PI )  * radialDistance / 4.46783504 - xSlider;//Use For Rainbow Spiral Multiply radialDistance By 10 To Increase The Number Of Spirals //Use This: "a = ( - angle + Math.PI ) * radialDistance;" Line For Rainbow Clock //a = ( - angle * Math.tan( angle ) + Math.PI ) * radialDistance - xSlider; For Infinite Number Theorem //a = ( - angle * Math.cos( angle ) * Math.sin( angle ) * Math.pow(radialVariableDistance, 2) + Math.PI ) * radialDistance - xSlider; */
							radius = a * 10;
							// *///For Old Infinite Number Theorem Use Above
							//radius = a * 10;//For Rainbow Spiral And Clock
							//}
							while ( radius < colorDisplacement)//For Rainbow Ring
								radius = radius + fullAngle - colorDisplacement;//BAD COMMENT: For Rainbow Ring Take Out - 38
							while ( radius > fullAngle )//radius > fullAngle For Non Infinite Number Theorem
								radius = radius - fullAngle - colorDisplacement; //radius = radius - fullAngle; For Non Infinite Number Theorem //For Rainbow Clock Comment Out To Here. Here -- */
							if ( radius >= colorDisplacement && radius < (numberOfColorsInTheRainbow - 1) * colorInterval  + colorDisplacement)//For Purple Outside Ring
							{
								if ( radius < colorInterval  + colorDisplacement)//For Normal Rainbow Use This Instead Of The Others
									color.ColorSliderFunction(colorInterval, radius - colorDisplacement, white, skyblue);
								else if ( radius < ( 2 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - colorInterval - colorDisplacement, skyblue, pink);
								else if ( radius < ( 3 * colorInterval  + colorDisplacement) )		
									color.ColorSliderFunction(colorInterval, radius - 2 * colorInterval - colorDisplacement, pink, blue);
								else if ( radius < ( 4 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 3 * colorInterval - colorDisplacement, blue, red);
								else if ( radius < ( 5 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 4 * colorInterval - colorDisplacement, red, purple);
								else if ( radius < ( 6 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 5 * colorInterval - colorDisplacement, purple, orange);
								else if ( radius < ( 7 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 6 * colorInterval - colorDisplacement, orange, green);
								else if ( radius < ( 8 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 7 * colorInterval - colorDisplacement, green, yellow);
								else if ( radius < ( 9 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 8 * colorInterval - colorDisplacement, yellow, teal);
								else if ( radius < ( 10 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 9 * colorInterval - colorDisplacement, teal, bronze);
								else if ( radius < ( 11 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 10 * colorInterval - colorDisplacement, bronze, silver);
								else if ( radius < ( 12 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 11 * colorInterval - colorDisplacement, silver, gold);
								else if ( radius < ( 13 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 12 * colorInterval - colorDisplacement, gold, lime);
								else
									color.ColorSliderFunction(colorInterval, radius - 13 * colorInterval - colorDisplacement, lime, brown);

							}
							background[3 * x + Dim.width * 3 * y + 0] = (int)color.RGB[0];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 0]
							background[3 * x + Dim.width * 3 * y + 1] = (int)color.RGB[1];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 1]
							background[3 * x + Dim.width * 3 * y + 2] = (int)color.RGB[2];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 2]//*/
							//wr.setPixel( x, y, color.RGB );//(double[])red.get()); //Use For Fade-Ins And Fade-Outs And This Command Makes Everything Change On The Actual Screen
							//I.setRGB(x, y, (int)((int)color.RGB[0] * 65536 + (int)color.RGB[1] * 256 + (int)color.RGB[2]));//* //ASDF HERE HERE HERE HERE HERE
							pw.setArgb( x, y, (int)(255 * 16777216 + (int)color.RGB[0] * 65536 + (int)color.RGB[1] * 256 + (int)color.RGB[2]));
							//ASDFpw.setArgb( x, y, (int)(255 * 16777216 + (int)color.RGB[0] * 65536 + (int)color.RGB[1] * 256 + (int)color.RGB[2]));
						}//ASDF
					}//ASDF

					//wr.setPixels(0, 0, Dim.width, Dim.height, background);//wr.setPixels(0, 0, Dim.width + 1, Dim.height, background);//wr.setPixels(0, 0, HalfedDim.width * 2 + 1, HalfedDim.height * 2, background);//For NonUniform Background Colors
					//I.setData(wr);

					//f.invalidate();
					//f.revalidate();
					//f.repaint();
					/*
							label = new Label("My label");
							font = new Font("Techno Hideo", Font.PLAIN, 10);
							label.setFont( font );
							label.setHorizontalAlignment(SwingConstants.CENTER);
							label.setText(text);
							while ( label.getFontMetrics(font).stringWidth(text) <= Dim.width )
							{
								font = new Font("Techno Hideo", Font.PLAIN, font.getSize() + 1);
								label.setFont( font );
							}
							font = new Font("Techno Hideo", Font.PLAIN, font.getSize() - 10);
							label.setFont( font );

							label.revalidate();
							label.validate();
							label.repaint();
							label.setVisible(true);//*/

					//textWidth = label.getFontMetrics(font).stringWidth(text);
					/*xBlankSize = (Dim.width - textWidth) / 2;
					//yTextSize = label.getFontMetrics(font).getHeight();
					colorInterval2 = ( Dim.width - 2 * xBlankSize )/ ( numberOfColorsInTheRainbow - 1 );
					for (x = xBlankSize - 1; x < Dim.width - xBlankSize; x++)//x < HalfedDim.width * 2//For old Background Raster ( HalfedDim.width * 2 )// For Fractals And Rainbow Sliders And ??? ///To Test Moving Rainbow From Left To Right
					{
						for (y = 0; y < yTextSize; y++)//y < HalfedDim.height * 2//For old Background Raster ( HalfedDim.height * 2 )//Comment Out Here For NonFractals
						{

							tempColor = I.getRGB(x, y);
							tempBlue = tempColor & 0xff;
							tempGreen = (tempColor & 0xff00) >> 8;
							tempRed = (tempColor & 0xff0000) >> 16;
								testColor.set(new double[] {tempRed, tempGreen, tempBlue} );//ASDF HERE HERE HERE HERE HERE
								//System.out.println( testColor );
								if ( testColor.get() == black.get() );
								{
									radius = x - xBlankSize + 1 + xSlider;
									while ( radius < colorDisplacement)//For Rainbow Ring
										radius = radius + textWidth - colorDisplacement;
									if ( radius < colorInterval2  + colorDisplacement)//For Normal Rainbow Use This Instead Of The Others
										color.ColorSliderFunction(colorInterval2, radius - colorDisplacement, white, skyblue);
									else if ( radius < ( 2 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - colorInterval2 - colorDisplacement, skyblue, pink);
									else if ( radius < ( 3 * colorInterval2  + colorDisplacement) )		
										color.ColorSliderFunction(colorInterval2, radius - 2 * colorInterval2 - colorDisplacement, pink, blue);
									else if ( radius < ( 4 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 3 * colorInterval2 - colorDisplacement, blue, red);
									else if ( radius < ( 5 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 4 * colorInterval2 - colorDisplacement, red, purple);
									else if ( radius < ( 6 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 5 * colorInterval2 - colorDisplacement, purple, orange);
									else if ( radius < ( 7 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 6 * colorInterval2 - colorDisplacement, orange, green);
									else if ( radius < ( 8 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 7 * colorInterval2 - colorDisplacement, green, yellow);
									else if ( radius < ( 9 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 8 * colorInterval2 - colorDisplacement, yellow, teal);
									else if ( radius < ( 10 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 9 * colorInterval2 - colorDisplacement, teal, bronze);
									else if ( radius < ( 11 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 10 * colorInterval2 - colorDisplacement, bronze, silver);
									else if ( radius < ( 12 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 11 * colorInterval2 - colorDisplacement, silver, gold);
									else if ( radius < ( 13 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 12 * colorInterval2 - colorDisplacement, gold, lime);
									else
										color.ColorSliderFunction(colorInterval2, radius - 13 * colorInterval2 - colorDisplacement, lime, brown);
								}
								y = y + Dim.height / 260;
								background[3 * x + Dim.width * 3 * y + 0] = (int)color.RGB[0];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 0]
								background[3 * x + Dim.width * 3 * y + 1] = (int)color.RGB[1];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 1]
								background[3 * x + Dim.width * 3 * y + 2] = (int)color.RGB[2];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 2]//*/
								//ASDFpw.setArgb( x, y, (int)(255 * 16777216 + (int)color.RGB[0] * 65536 + (int)color.RGB[1] * 256 + (int)color.RGB[2]));
								//Color colorJFX = pr.getColor( x, y);

								//wr.setPixel( x, y, color.RGB );//(double[])red.get()); //Use For Fade-Ins And Fade-Outs And This Command Makes Everything Change On The Actual Screen
								//I.setRGB(x, y, (int)((int)color.RGB[0] * 65536 + (int)color.RGB[1] * 256 + (int)color.RGB[2]));
								/*y = y - Dim.height / 260;
						}
					}*/
					/*
							label.setVisible(false);
							label.revalidate();
							label.validate();
							label.repaint();//*/
					/*
					WritableImage wi = null;
			        if (I != null) {
			            wi = new WritableImage(I.getWidth(), I.getHeight());
			            PixelWriter pw = wi.getPixelWriter();
			            for (x = 0; x < I.getWidth(); x++) {
			                for (y = 0; y < I.getHeight(); y++) {
			                    pw.setArgb(x, y, I.getRGB(x, y));
			                }
			            }
			        }*/
					// Display image on screen
			        imageView.setImage(wi);
					StackPane root = new StackPane();
					root.getChildren().add(imageView);
					Scene scene = new Scene(root, primaryStage.getWidth(), primaryStage.getHeight());
					primaryStage.setTitle("Sonnet");
					primaryStage.setScene(scene);
					primaryStage.setResizable(true);
					primaryStage.setMaximized(true);
					primaryStage.show();
					//image = wr.setPixels(0, 0, Dim.width, Dim.height, background);//wr.setPixels(0, 0, Dim.width + 1, Dim.height, background);//wr.setPixels(0, 0, HalfedDim.width * 2 + 1, HalfedDim.height * 2, background);//For NonUniform Background Colors
					//I.setData(wr);

					//f.add(label, BorderLayout.PAGE_START);

					/*if ( doneWritingFirstImage == false && xSlider == 0)
						{
							try{ ImageIO.write(I, "png", new File(selectedFile.getPath() ) ); Thread.sleep(100); }
							catch (Exception ex) {ex.printStackTrace();}
							doneWritingFirstImage = true;
							System.exit(0);
						}//*/
					//if ( xSlider >= 0 )
					//{
						//try{ enc.encodeImage(pw);
						//try{ enc.encodeImage(I);/* Thread.sleep(100); */}
						//catch (Exception ex) {ex.printStackTrace();}
					//}
					//}//Comment Out This Line For No Primary NonSlider Loop.
					//System.out.println( xSlider );
					//System.out.println( (HalfedDim.width * 2 + 1) + " " + (HalfedDim.height * 2));
					//System.out.println( (HalfedDim.width * 2 + 1) + " " + (HalfedDim.height * 2));
					//System.out.println(selectedFile.getPath());
					//I = new BufferedImage(BufferedImage.TYPE_INT_RGB, wr, false, null);
					//wr = I.getRaster();
					//try{enc.encodeImage(wr.getPixels(0, 0, HalfedDim.width * 2, HalfedDim.height * 2, background));}
					/*try //Use This To Slow Down The Movement Of The xSlider
						{
							Thread.sleep(100);
						}
						catch (Exception ex)
						{
							ex.printStackTrace();
						}//*/
					//wr.wait(4000);
					//f.invalidate();
					//f.revalidate();
					//f.repaint();
					//wr.notify();
					xSlider = xSlider + interval;//For Hypnosis Sun
					//stage.show();
					//}
					//USE FOR xSlider for statement above
					/*for (x = 0; x < ( HalfedDim.width * 2 ); x++)// For Fractals And Rainbow Sliders And ??? ///To Test Moving Rainbow From Left To Right
						for (y = 0; y < ( HalfedDim.height * 2 ); y++)//Comment Out Here For NonFractals
							wr.setPixel(x, y, green.RGB);//DO NOT USE */

					//try{enc.finish();}
					//catch (Exception ex)
					//{ex.printStackTrace();}
					//System.exit(0);//*/
					//USE ABOVE FOR NEW CIRCULAR RAINBOWS
				}
			}
			else if (choice == 1)
			{
				//Dim = f.getSize();

				//Thread.sleep(1000);
				choice = 2;
			}
			else if (choice == 2)
			{
				//Dim = f.getSize();

				//Thread.sleep(1000);
				choice = 4;
			}
		}
	}

	/*
	//@Override
	public void start(Stage stage) throws Exception
	{

		//canvas.widthProperty().addListener(observable -> redraw());
		//canvas.heightProperty().addListener(observable -> redraw());

		System.out.println( initialScreenSizeX );
		System.out.println( initialScreenSizeY );

		System.out.println(Dim);
		//StackPane stackPane = new StackPane();
		//canvas.setWidth(Dim.width);
		//canvas.setWidth(Dim.height);
		//canvas.minWidth(400);
		//canvas.minHeight(400);
		//canvas.setVisible(true);
		//GraphicsContext gc = canvas.getGraphicsContext2D();





		stage.setWidth(Dim.width);
		stage.setHeight(Dim.height);
		//stackPane.setWidth(Dim.width);
		//stackPane.setWidth(Dim.height);
		//stackPane.getChildren().addAll(new Rectangle(Dim.width, Dim.height, Color.BLUE), new Label("Go!"));
		//canvas.getGraphicsContext2D().setFill(Color.BLACK);
		//canvas.getGraphicsContext2D().fillRect(0, 0, Dim.width, Dim.height);

		//canvas.setWidth(initialScreenSizeX);
		//canvas.setHeight(initialScreenSizeY);



		stackPane.getChildren().add(canvas);
		// Bind canvas size to stack pane size.
		//canvas.widthProperty().bind(
		//		stackPane.widthProperty());
		//canvas.heightProperty().bind(
		//		stackPane.heightProperty());


		//stage.setScene(new Scene(root, initialScreenSizeX, initialScreenSizeY, Color.BLACK) );
		stage.setTitle("Sonnet");

		stage.setMaximized(true);

		stage.show();

		//Dim.width = (int)canvas.getWidth();
		//Dim.height = (int)canvas.getHeight();

	}*/

	static public void main(String[] args) throws IOException//throws InterruptedException
	{
		//new Sonnet();
		launch(args);
		//f.setExtendedState(JFrame.MAXIMIZED_BOTH);//Comment Out For 4K UHD
	}

	/*Sonnet()
	{
		new Thread( () -> rainbowSystem() ).start();
		//f.setExtendedState(JFrame.MAXIMIZED_BOTH);//Comment Out For 4K UHD
	}//*

	//public static void main(String[] args)
	//{ launch(args); }

	static int initialScreenSizeX = 1920, initialScreenSizeY = 1080;//1920x1080//3840, 2160//1440, 900 //3858, 2200//862
	static Dimension Dim = new Dimension(initialScreenSizeX, initialScreenSizeY), DimCheck = new Dimension(initialScreenSizeX, initialScreenSizeY), HalfedDim = new Dimension( Math.round( ( Dim.width + 1 ) / 2 - 1 ), Math.round( ( Dim.height - 37 ) / 2 - 1 ) ), DimLabel = new Dimension(1,1);
	//static Group root = new Group();
	//static Stage stage;
	//static StackPane stackPane = new StackPane();//static JFrame f = new JFrame("Sonnet");
	//static Canvas canvas = new Canvas();
	static BufferedImage I = new BufferedImage(Dim.width, Dim.height, BufferedImage.TYPE_INT_RGB);
	//static WritableRaster wr = I.getRaster();
	static JFileChooser fileChooser = new JFileChooser();
	static String path = "C:\\TestVideo.mp4", text = "Sky.Netarianism";//"C:\\TestImage.png"//"C:\\TestVideo.mp4"//"C:\\TEMP_Sonnet.mp4";
	static File selectedFile = new File (path);
	static boolean doneWritingFirstImage = false;
	static SequenceEncoder enc;// = new SequenceEncoder(selectedFile);
	//static SequenceEncoder enc = new SequenceEncoder(selectedFile);
	static int borderSizeX = Dim.width/12, borderSizeY = Dim.height/6;
	static int choice = 0;//0 is SkyNet Pyramid, 1 is Full Spectral Rainbow, 2 is Y and Sonnet
	static final int numberOfColorsInTheRainbow = 15;//asdf Always Worry About This!
	static final ColorSlider black = new ColorSlider( new double[]{0,0,0} );
	static final ColorSlider white = new ColorSlider( new double[]{255,255,255} );
	static final ColorSlider skyblue = new ColorSlider( new double[]{134,206,249} );
	static final ColorSlider pink = new ColorSlider( new double[]{255,64,143} );
	static final ColorSlider blue = new ColorSlider( new double[]{0,0,192} );
	static final ColorSlider red = new ColorSlider( new double[]{193,0,0} );
	static final ColorSlider purple = new ColorSlider( new double[]{122,0,178} );
	static final ColorSlider orange = new ColorSlider( new double[]{255,134,0} );
	static final ColorSlider green = new ColorSlider( new double[]{0,133,50} );
	static final ColorSlider yellow = new ColorSlider( new double[]{246,252,15} );
	static final ColorSlider teal = new ColorSlider( new double[]{3,224,149} );
	static final ColorSlider bronze = new ColorSlider( new double[]{152,123,46} );
	static final ColorSlider silver = new ColorSlider( new double[]{193,192,192} );
	static final ColorSlider gold = new ColorSlider( new double[]{205,191,44} );
	static final ColorSlider lime = new ColorSlider( new double[]{126,193,33} );
	static final ColorSlider brown = new ColorSlider( new double[]{131,103,71} );

	//	public class Canvas extends Canvas {
	/*
		@Override
		public double minHeight(double width)
		{
		    return 1000;
		}

		@Override
		public double maxHeight(double width)
		{
		    return 2160;
		}

		@Override
		public double prefHeight(double width)
		{
		    return minHeight(width);
		}

		@Override
		public double minWidth(double height)
		{
		    return 100;
		}

		@Override
		public double maxWidth(double height)
		{
		    return 4320;
		}//*/
	/*
		@Override
		public boolean isResizable()
		{
		    return true;
		}

		@Override
		public void resize(double width, double height)
		{
		    super.setWidth(width);
		    super.setHeight(height);
		    //paint();
		}

		public ResizableCanvas()
		{
			// Redraw canvas when size changes.
			widthProperty().addListener(evt -> rainbowSystem());
			heightProperty().addListener(evt -> rainbowSystem());
		}
	 */
	public void rainbowSystem()
	{

		//double width = getWidth();
		//double height = getHeight();


		//Dim.width = (int)canvas.getWidth();
		//Dim.height = (int)canvas.getHeight();
		System.out.println(Dim + " Here!");
		//GraphicsContext gc = canvas.getGraphicsContext2D();

		/*gc.clearRect(0, 0, Dim.width, Dim.height);
		gc.setStroke(Color.BLACK );
		gc.strokeLine(0, 0, Dim.width, Dim.height);
		gc.strokeLine(0, Dim.height, Dim.width, 0);
		 */




		/*BufferedImage I = null;
		try {

			URL url = new URL("http://skynetarianism.net/Pictures/KnightsOfTheSciMagOrder.png");
			I = ImageIO.read(url);

			//ImageIO.write(image, "jpg",new File("C:\\out.jpg"));
			//ImageIO.write(image, "gif",new File("C:\\out.gif"));

			ImageIO.write(I, "png", new File("KnightsOfTheSciMagOrder.png") );

		} catch (IOException e) {
			e.printStackTrace();
		}//*/
		//WritableImage wr = new WritableImage(Dim.width, Dim.height);
		//PixelWriter pw = gc.getPixelWriter();
		/*ImageView imageView = new ImageView(wr);

		imageView.setFitWidth(Dim.width);
		imageView.setFitHeight(Dim.height);
		imageView.setSmooth(true);


		Pane pane = new Pane(imageView);
		Scene offScreenScene = new Scene(pane);
		WritableImage croppedImage = imageView.snapshot(null, null);*/


		//stage.show();


		//Dim.width = (int)width;
		//Dim.height = (int)height;

		//gc.setStroke(Color.RED);
		//gc.strokeLine(0, 0, width, height);
		//gc.strokeLine(0, height, width, 0);
		/*fileChooser.setSelectedFile(selectedFile);
			int returnValue = fileChooser.showSaveDialog(null);
			if (returnValue == JFileChooser.APPROVE_OPTION)
			{
				selectedFile = fileChooser.getSelectedFile();
				System.out.println(selectedFile.getName());
				System.out.println(selectedFile.getPath());
			}//*/
		//if (selectedFile != null)
		//{
		int x = 0, y = 0, xMinusxSlider = 0, yMinusxSlider = 0, cxMx = 0, ySlider = 0, yMinusySlider = 0, cyMy = 0;//cxMx Corrected xMinusSlider for determining color
		ColorSlider color = new ColorSlider( new double[]{0,0,0} ), testColor = new ColorSlider( new double[]{0,0,0} );
		int tempColor = 0;
		int tempBlue = 0;
		int tempGreen = 0;
		int tempRed = 0;
		int [] background = {255, 255, 255};
		double colorInterval = 0, a = 0, b = 0, xSlider = 0, xSliderInitial = 0, xSliderFactor = 10, xSliderBackAndFourth = 1;//Dim.width / ( numberOfColorsInTheRainbow - 1 );
		int cx = Math.round( (Dim.width + 1  ) / 2 - 1 );//Uncomment For Circular Rainbow
		int cy = Math.round( (Dim.height - 60 + 1 ) / 2 - 1 );//Uncomment For Circular Rainbow
		double xSliderZoomFactor = 0.1;
		double totalAngleUnits = 0;//Uncomment For Circular Rainbow
		//double spectralBrightnessMultiplyer = 1/2;
		boolean TrispectralRainbow = false;
		//Dimension DimLast = Dim;
		//Thread.sleep(4000);
		while (choice != 4)
		{
			if (choice == 0)
			{
				//Dimension DimLast = Dim;
				//f.setExtendedState(JFrame.MAXIMIZED_BOTH);//Comment Out For 4K UHD
				//Dim.width = (int)canvas.getWidth();
				//Dim.height = (int)canvas.getHeight();

				System.out.println( Dim );
				//Dim = f.getSize();//Dim = f.getContentPane().getSize();
				//f.setPreferredSize(Dim);//Comment Out For 4K UHD
				/*HalfedDim.width = Math.round( ( Dim.width + 1 ) / 2 - 9 );//For Fractal Use No: - 1 At The Other End Otherwise No
					HalfedDim.height = Math.round( ( Dim.height - 37 ) / 2 - 1 );//For Fractal Use No: - 1 At The Other End Otherwise No
				 */
				HalfedDim.width = Math.round( Dim.width / 2 );
				HalfedDim.height = Math.round( Dim.height / 2 );
				//I = new BufferedImage(HalfedDim.width * 2, HalfedDim.height * 2, BufferedImage.TYPE_INT_RGB);
				//DimCheck = Dim;
				//cy = Math.round( (Dim.height + 1 ) / 2 - 1 );//Use Only For Circular Rainbow When Not Moving
				Label label = new Label("My label");
				//Font font = new Font("Techno Hideo", Font.PLAIN, 10);
				colorInterval = Dim.width / ( numberOfColorsInTheRainbow - 1 );//Use For Noncircular Rainbow And Fractal
				//colorInterval = Dim.height / ( 2 * ( numberOfColorsInTheRainbow - 1 ) );//Use Only for Circular Rainbow Without xSlider
				//colorInterval = ( Dim.height - 53 ) / ( 2 * ( numberOfColorsInTheRainbow - 1 ) );//Use Only for Circular Rainbow
				if (TrispectralRainbow == true)
					colorInterval = colorInterval / 3;//For Trispectral Rainbow.
				//double colorDisplacement = HalfedDim.height * (1 - 0.175979734764);//For Thin Rainbow Ring
				//double colorDisplacement = HalfedDim.height * (1 - 0.5);//For Thick Rainbow Ring
				double colorDisplacement = 0;//For Rainbow Disk And 0 Rainbow Clock
				double radialDistance = Math.pow(Math.pow(HalfedDim.width + 1, 2) + Math.pow(HalfedDim.height + 1, 2), 0.5);//For Clock And Rainbow Spiral No Whole Thing / 12 That Is For Fractal.
				double radialVariableDistance = radialDistance;
				double fullAngle = Math.PI * radialDistance;//For Hypnosis Spiral 2 * Math.PI * radialDistance
				double angle = 0;
				double radius = radialVariableDistance * 14.4 + colorDisplacement + angle;
				double interval = fullAngle / 10 / 111;//Last Division Determines The Frame Rate
				//JLabel label = new JLabel("My label");
				//Font font = new Font("Techno Hideo", Font.PLAIN, 10);
				int textWidth = 0;
				int xBlankSize = 0;
				int yTextSize = 0;
				double colorInterval2 = 100;
				xSlider = (int)Math.round(colorDisplacement) - 2 * interval;//For JCodec
				xSliderInitial = xSlider;
				while (xSlider < fullAngle / 10)//To Make Full Video !!!!USE ME!!!!:while (xSlider < fullAngle) //For JCodec
					//Without JCodec: for ( xSlider = (int)Math.round(colorDisplacement); xSlider < fullAngle; xSlider++)// For Fractal: (xSlider = 1 + (int)Math.round(colorDisplacement); xSlider <= 480; xSlider++) Or xSlider = xSlider + 0.00025, For Spirals xSlider < fullAngle For Fade-ins And Fade-outs xSlider <= 255 To Different Colors< For Rainbow Clock, xSlider = (int)Math.round(colorDisplacement); For Rings -144 Use cy And < HalfedDim.height Instead of Dim.height For Circular Rainbow Use Dim.width < For Rainbow Slider And Fractal //Start At -144 For Videos And Pictures
				{//0.175979734764 * 
					if (xSliderInitial == xSlider)
					{
						/*selectedFile.getParentFile().mkdirs(); 
								try{if(!selectedFile.exists())selectedFile.createNewFile();}
								catch(IOException ex){System.out.println("Unable to create " + selectedFile.getPath() + ": "+ex.getMessage());}
								try{enc = new SequenceEncoder(selectedFile);}
								catch (Exception ex)
								{ex.printStackTrace();}*/

						//Dim.width = (int)canvas.getWidth();
						//Dim.height = (int)canvas.getHeight();

						//Dim = f.getSize();//Dim = f.getContentPane().getSize();
						//System.out.println( Dim );
						radialDistance = Math.pow(Math.pow(HalfedDim.width + 1, 2) + Math.pow(HalfedDim.height + 1, 2), 0.5);//For Clock And Rainbow Spiral No Whole Thing / 12 That Is For Fractal.
						radialVariableDistance = radialDistance;
						fullAngle = Math.PI * radialDistance;//For Hypnosis Spiral 2 * Math.PI * radialDistance
						angle = 0;
						radius = radialVariableDistance * 14.4 + colorDisplacement + angle;
						interval = fullAngle / 10 / 111;//Last Division Determines The Frame Rate

					}
					//xSlider = (int)Math.round(colorDisplacement);//For No Slider Rainbow Ring
					//xSlider = 0;//For No Slider Rainbow Disk
					//f.setResizable(false);
					//Dim = f.getSize();//Dim = f.getContentPane().getSize();
					//System.out.println( Dim );
					/*HalfedDim.width = Math.round( ( Dim.width + 1 ) / 2 - 9 );//For Fractal Use No: - 1 At The Other End Otherwise No
						HalfedDim.height = Math.round( ( Dim.height - 37 ) / 2 - 1 );//For Fractal Use No: - 1 At The Other End Otherwise No
					 */
					HalfedDim.width = Math.round( Dim.width / 2 );
					HalfedDim.height = Math.round( Dim.height / 2 );
					background = new int[Dim.width * Dim.height * 3];//background = new int[(HalfedDim.width * 2 + 1) * (HalfedDim.height * 2) * 3]//Use To Fix Left Side Raster Mess Up
					radialDistance = Math.pow(Math.pow(HalfedDim.width + 1, 2) + Math.pow(HalfedDim.height + 1, 2), 0.5);//For Clock And Rainbow Spiral
					/*if (Dim != DimCheck)
				{
					for (int xRefresh = 0; xRefresh < Dim.width; xRefresh++)
						for (int yRefresh = 0; yRefresh < Dim.height - 16; yRefresh++)
							wr.setPixel(xRefresh, yRefresh, black.RGB);
					DimCheck = Dim;
				}//*/
					//f.setResizable(true);
					//Uncomment For Smaller And Smaller Circles When Resized
					/*if (xSlider < 240)//For Fractal
						xSliderBackAndFourth = xSlider;//For Fractal
					else//For Fractal
						xSliderBackAndFourth = 480 - xSlider;//For Fractal*/
					//xSliderZoomFactor = 0.1;//Math.pow(xSliderBackAndFourth , 0.24) Use Only For Fractal In Certain Case
					//xSliderFactor = 6.48 * Math.sin(8.864 * xSlider / HalfedDim.height) * Math.pow(xSliderBackAndFourth , 1.20);//Use Only For Fractal*/
					//colorInterval = ( Dim.height - 53) / ( 2 * ( numberOfColorsInTheRainbow - 1 ) ) * 0.175979734764;//For Thin Rainbow Ring, Use Only for Circular Rainbow * 0.175979734764
					//colorInterval = ( Dim.height - 53) / ( 2 * ( numberOfColorsInTheRainbow - 1 ) ) * 0.5;//For Thick Rainbow Ring, Use Only for Circular Rainbow * 0.175979734764
					fullAngle = 2 * Math.PI * radialDistance;// * 4.46783504;//For Rainbow Clock And Spiral fullAngle = 2 * Math.PI * radialDistance;
					colorInterval = fullAngle / ( numberOfColorsInTheRainbow - 1 );//For Rainbow Clock And Spiral
					//colorInterval = HalfedDim.height / ( numberOfColorsInTheRainbow - 1 );//For Rainbow Disk
					//colorInterval = colorInterval * 0.175979734764;//USE ONLY FOR VIACAD EMBLEM
					//colorDisplacement = HalfedDim.height * (1 - 0.175979734764);
					//colorDisplacement = HalfedDim.height * (1 - 0.5);//For Thick Rainbow Ring
					colorDisplacement = 0;//For Rainbow Disk
					//colorInterval = HalfedDim.width * 2 / ( numberOfColorsInTheRainbow - 1 );//For Fractals And Other Noncircular Rainbows*/
					//colorInterval = 100 / ( numberOfColorsInTheRainbow - 1 );//For Fade-Ins And Fade-Outs
					//cx = Math.round( (Dim.width + 1  ) / 2 - 1 );//Use Only For Circular Rainbow
					//cy = Math.round( (Dim.height - 37 ) / 2 - 1 );//Use Only For Circular Rainbow
					//ySlider =  xSlider * Dim.height / Dim.width;*/
					//for (x = 0; x < Dim.width; x++)//Comment Out Here For Circular Rainbow And Fade-Ins And Fade-Outs
					//{//Comment Out Here For Circular Rainbow
					//xMinusxSlider = x - xSlider;// To Test Moving Rainbow From Left To Right
					//xMinusxSlider = x;//For Testing Only!
					for (x = 0; x < Dim.width; x++)//x < HalfedDim.width * 2//For old Background Raster ( HalfedDim.width * 2 )// For Fractals And Rainbow Sliders And ??? ///To Test Moving Rainbow From Left To Right
					{
						/*if ( xMinusxSlider < 0 )//To Test Moving Rainbow From Left To Right
							cxMx = xMinusxSlider + Dim.width;//To Test Moving Rainbow From Left To Right
						else cxMx = xMinusxSlider;//To Test Moving Rainbow From Left To Right
						colorInterval = 256 / numberOfColorsInTheRainbow;//Use Only For Background Full Screen Colors*/
						for (y = 0; y < Dim.height; y++)//y < HalfedDim.height * 2//For old Background Raster ( HalfedDim.height * 2 )//Comment Out Here For NonFractals
						{
							radialVariableDistance = Math.pow(Math.pow(x - HalfedDim.width + 1, 2) + Math.pow( y - HalfedDim.height + 1, 2), 0.5);//Comment Out For  Ghetto Many Rainbow Clocks 
							//if ( ( y - HalfedDim.height + 1) != 0)// && y != 0
							//a = ( - Math.atan2( (x - HalfedDim.width + 1) , (y - HalfedDim.height + 1 ) ) + Math.PI ) * radialDistance - xSlider;//Use For Rainbow Spiral Multiply radialDistance By 10 To Increase The Number Of Spirals //Use This: "a = ( - Math.atan2( (x - HalfedDim.width + 1) , (y - HalfedDim.height + 1 ) ) + Math.PI ) * radialDistance;" Line For Rainbow Clock
							//b = - ( ( y + xSliderBackAndFourth / HalfedDim.height - HalfedDim.height ) - ( x + 24 * xSliderBackAndFourth / HalfedDim.height - 4 * HalfedDim.width ) * 2 * HalfedDim.width / ( y - HalfedDim.height ) / (2 * HalfedDim.width) ) * xSliderFactor;//Comment Out For  Ghetto Many Rainbow Clocks
							//else //For Rainbow Clock ???
							//else
							//	a = ( - Math.atan2( (x - HalfedDim.width + 1) , 0.00001 ) + Math.PI ) * radialDistance - xSlider;//Use For Rainbow Spiral Multiply radialDistance By 10 To Increase The Number Of Spirals //Use This: "a = ( - Math.atan2( (x - HalfedDim.width + 1) , (y - HalfedDim.height + 1 ) ) + Math.PI ) * radialDistance;" Line For Rainbow Clock */
							/*{//Use This Command Tree For Rainbow Clock And Maybe Other Things
							if ( x - HalfedDim.width + 1 > 0 )
								a = Math.PI / 2 * radialDistance;
							else
								a = 3 * Math.PI / 2 * radialDistance;
							}// Do Not Use Above For Rainbow Spiral*/
							//radius = a;//Use For Rainbow Clock And And Don't For Rainbow Spiral
							/*while (b > .4 || b < -.4)//For Rainbow Clock Comment From Here To:-- And Don't For Rainbow Spiral
								b = b / 10;
							if ( b == 0 )
								b = 1;
							while ( a < 0 )
								a = (a + 6 * colorInterval);
							while ( a > 6 * colorInterval )
								a = (a - 6 * colorInterval);//Use Above For Fractal Only*/
							/*if (a < 0)
									a = a + fullAngle;
								else
									if (a > fullAngle)
										a = a - fullAngle;*/
							// Comment Out Below Till It Says To Stop For Rainbow Clock
							//if (radialVariableDistance < radialDistance / 4) // For Hypnosis Sun Append On End: / 4)//Use To Cut Out What Is Beyond A Circle And Make Something With This else.
							//{
							//	if ( ( y - HalfedDim.height + 1) != 0 )// && y != 0
							//		a = ( - Math.atan2( (x - HalfedDim.width + 1) , (y - HalfedDim.height + 1 ) ) + Math.PI ) * radialDistance - xSlider;//Use For Rainbow Spiral Multiply radialDistance By 10 To Increase The Number Of Spirals //Use This: "a = ( - Math.atan2( (x - HalfedDim.width + 1) , (y - HalfedDim.height + 1 ) ) + Math.PI ) * radialDistance;" Line For Rainbow Clock */
							//	else
							//		a = ( - Math.atan2( (x - HalfedDim.width + 1) , 0.00001 ) + Math.PI ) * radialDistance - xSlider;//Use For Rainbow Spiral Multiply radialDistance By 10 To Increase The Number Of Spirals //Use This: "a = ( - Math.atan2( (x - HalfedDim.width + 1) , (y - HalfedDim.height + 1 ) ) + Math.PI ) * radialDistance;" Line For Rainbow Clock */
							//	//if (b != 0 )//For BAD Shrunken
							//		radius =  radialVariableDistance * 33.3 + colorDisplacement + a * 5;//For Hypnosis Sun: radius = radialVariableDistance * 44.6 + colorDisplacement + a; For CERTAIN Fractal: radius =  radialVariableDistance + colorDisplacement + a / b * 1 / 0.4; For BAD Shrunken And Maybe FRACTAL!!!! radius =  radialVariableDistance * 14.4 + colorDisplacement + a / b * 1 / 0.4; ,, For Shrunken radius =  radialVariableDistance * 33.3 + colorDisplacement + a * 5; For Super Many Shrunken radius = radialVariableDistance * 66.6 + colorDisplacement + a * 10; For Hypnosis Spiral radius = radialVariableDistance * 24.6 + colorDisplacement + a; For MiniHypnosis Spiral And Spiral Prism radius = radialVariableDistance * 66.6 + colorDisplacement + a;
							//else//For BAD Shrunken
							//	radius = radialDistance / 4;//For BAD Shrunken
							//}
							//else
							//{

							if ( y - HalfedDim.height + 1 != 0) //y - HalfedDim.height + 1 < -tolerance || y - HalfedDim.height + 1 > tolerance )// OLD: ( y - HalfedDim.height + 1) != 0 && y != 0 //Use For Old Infinite Number Theorem Down
								angle = Math.atan2( (x - HalfedDim.width + 1) , (y - HalfedDim.height + 1 ) );
							else
								angle = Math.atan2( (x - HalfedDim.width + 1), 0.0002 );
							//	angle = Math.atan( x - HalfedDim.width + 1 / ( y - HalfedDim.height + 1 ) );//WON'T WORK FOR NO GOOD REASON
							//else//WON'T WORK FOR NO GOOD REASON
							//	angle = Math.atan( x - HalfedDim.width + 1 / .0002 );//WON'T WORK FOR NO GOOD REASONRenderedImage
							//	angle = Math.atan2( x - HalfedDim.width + 1, tolerance ); //Adjust The Small Number For Mostly Black Screen

							a = ( angle * /*Math.cos( angle ) * Math.sin( angle ) * Math.pow(radialVariableDistance, 1)*/ Math.tan( angle ) + Math.PI )  * radialDistance / 4.46783504 - xSlider;//For Infinite Number Theorem Good a = ( angle * /*Math.cos( angle ) * Math.sin( angle ) * Math.pow(radialVariableDistance, 1)*/ Math.tan( angle ) + Math.PI )  * radialDistance / 4.46783504 - xSlider;  //a = ( angle /*Math.cos( angle ) * Math.sin( angle ) * Math.pow(radialVariableDistance, 1)*/ Math.tan( angle ) + Math.PI )  * radialDistance / 4.46783504 - xSlider;//Use For Rainbow Spiral Multiply radialDistance By 10 To Increase The Number Of Spirals //Use This: "a = ( - angle + Math.PI ) * radialDistance;" Line For Rainbow Clock //a = ( - angle * Math.tan( angle ) + Math.PI ) * radialDistance - xSlider; For Infinite Number Theorem //a = ( - angle * Math.cos( angle ) * Math.sin( angle ) * Math.pow(radialVariableDistance, 2) + Math.PI ) * radialDistance - xSlider; */
							radius = a * 10;
							// *///For Old Infinite Number Theorem Use Above
							//radius = a * 10;//For Rainbow Spiral And Clock
							//}
							while ( radius < colorDisplacement)//For Rainbow Ring
								radius = radius + fullAngle - colorDisplacement;//BAD COMMENT: For Rainbow Ring Take Out - 38
							while ( radius > fullAngle )//radius > fullAngle For Non Infinite Number Theorem
								radius = radius - fullAngle - colorDisplacement; //radius = radius - fullAngle; For Non Infinite Number Theorem //For Rainbow Clock Comment Out To Here. Here -- */
							if ( radius >= colorDisplacement && radius < (numberOfColorsInTheRainbow - 1) * colorInterval  + colorDisplacement)//For Purple Outside Ring
							{
								if ( radius < colorInterval  + colorDisplacement)//For Normal Rainbow Use This Instead Of The Others
									color.ColorSliderFunction(colorInterval, radius - colorDisplacement, white, skyblue);
								else if ( radius < ( 2 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - colorInterval - colorDisplacement, skyblue, pink);
								else if ( radius < ( 3 * colorInterval  + colorDisplacement) )		
									color.ColorSliderFunction(colorInterval, radius - 2 * colorInterval - colorDisplacement, pink, blue);
								else if ( radius < ( 4 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 3 * colorInterval - colorDisplacement, blue, red);
								else if ( radius < ( 5 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 4 * colorInterval - colorDisplacement, red, purple);
								else if ( radius < ( 6 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 5 * colorInterval - colorDisplacement, purple, orange);
								else if ( radius < ( 7 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 6 * colorInterval - colorDisplacement, orange, green);
								else if ( radius < ( 8 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 7 * colorInterval - colorDisplacement, green, yellow);
								else if ( radius < ( 9 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 8 * colorInterval - colorDisplacement, yellow, teal);
								else if ( radius < ( 10 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 9 * colorInterval - colorDisplacement, teal, bronze);
								else if ( radius < ( 11 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 10 * colorInterval - colorDisplacement, bronze, silver);
								else if ( radius < ( 12 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 11 * colorInterval - colorDisplacement, silver, gold);
								else if ( radius < ( 13 * colorInterval  + colorDisplacement) )
									color.ColorSliderFunction(colorInterval, radius - 12 * colorInterval - colorDisplacement, gold, lime);
								else
									color.ColorSliderFunction(colorInterval, radius - 13 * colorInterval - colorDisplacement, lime, brown);

							}//Use Above For Rainbow Clock And Rainbow Spiral*/ 
							/*if ( a < 6 * colorInterval )//For Normal Rainbow Use This Instead Of The Others
							{
								if ( a < ( 1 * colorInterval ) )
								color.ColorSliderFunction(colorInterval, a, red, orange);
								else if ( a < ( 2 * colorInterval ) )
									color.ColorSliderFunction(colorInterval, a - colorInterval, orange, yellow);
								else if ( a < ( 3 * colorInterval ) )		
									color.ColorSliderFunction(colorInterval, a - 2 * colorInterval, yellow, green);
								else if ( a < ( 4 * colorInterval ) )
									color.ColorSliderFunction(colorInterval, a - 3 * colorInterval, green, teal);
								else if ( a < ( 5 * colorInterval ) )
									color.ColorSliderFunction(colorInterval, a - 4 * colorInterval, teal, blue);
								else
									color.ColorSliderFunction(colorInterval, a - 5 * colorInterval, blue, purple);
						}
						else color.RGB = black.RGB;//Use Above For Rainbow Fractal */

							//USE BELOW FOR NEW CIRCULAR RAINBOWS
							/*for (y = 0; y < Dim.height - 37; y++)
					for (x = 0; x < HalfedDim.width * 2; x++)
					{
						radialVariableDistance = Math.pow(Math.pow(x - HalfedDim.width + 1, 2) + Math.pow( y - HalfedDim.height + 1, 2), 0.5);//Comment Out For  Ghetto Many Rainbow Clocks
						angle = ( - Math.atan2( (x - HalfedDim.width + 1) , (y - HalfedDim.height + 1 ) ) + Math.PI ) * radialDistance - xSlider;//Use For Rainbow Spiral Multiply radialDistance By 10 To Increase The Number Of Spirals
						//Use To //For Rainbow Clock */ 
							/*double angle = ( Math.atan2( (x - HalfedDim.width + 1) , (y - HalfedDim.height + 1 ) ) + Math.PI ) * radialDistance + xSlider;
						if (angle < 0)
							angle = angle + fullAngle;
						else
							if (angle > fullAngle)
								angle = angle - fullAngle;
						//angle = 0;//Testing Purposes Only.
						/*if ( angle < colorInterval)//For Normal Rainbow Use This Instead Of The Others
							color.ColorSliderFunction(colorInterval, angle, red, orange);
						else if ( angle < 2 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - colorInterval, orange, yellow);
						else if ( angle < 3 * colorInterval )		
							color.ColorSliderFunction(colorInterval, angle - 2 * colorInterval, yellow, green);
						else if ( angle < 4 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 3 * colorInterval, green, teal);
						else if ( angle <  5 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 4 * colorInterval, teal, blue);
						else
							color.ColorSliderFunction(colorInterval, angle - 5 * colorInterval, blue, purple);//*/
							//while ( angle > 2 * colorInterval ) angle = angle - 2 * colorInterval; if ( angle < colorInterval) color.ColorSliderFunction(colorInterval, angle, green, blue); else color.ColorSliderFunction(colorInterval, angle - colorInterval, blue, green);
							/*if ( angle < colorInterval)//For Normal Rainbow Use This Instead Of The Others
							color.ColorSliderFunction(colorInterval, angle, green, blue);
						else if ( angle < 2 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - colorInterval, blue, green);
						else if ( angle < 3 * colorInterval )		
							color.ColorSliderFunction(colorInterval, angle - 2 * colorInterval, green, blue);
						else if ( angle < 4 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 3 * colorInterval, blue, green);
						else if ( angle <  5 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 4 * colorInterval, green, blue);
						else if ( angle <  6 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 5 * colorInterval, blue, green);
						else if ( angle <  7 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 6 * colorInterval, green, blue);
						else if ( angle <  8 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 7 * colorInterval, blue, green);
						else if ( angle <  9 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 8 * colorInterval, green, blue);
						else if ( angle <  10 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 9 * colorInterval, blue, green);
						else if ( angle <  11 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 10 * colorInterval, green, blue);
						else if ( angle <  12 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 11 * colorInterval, blue, green);
						else if ( angle <  13 * colorInterval )
							color.ColorSliderFunction(colorInterval, angle - 12 * colorInterval, green, blue);
						else
							color.ColorSliderFunction(colorInterval, angle - 13 * colorInterval, blue, green);//*/
							//yMinusxSlider = y - ySlider;// To Test Moving Rainbow From Left To Right
							//xMinusxSlider = x;//For Testing Only!
							/*if ( yMinusxSlider < 0 )// To Test Moving Rainbow From Left To Right USELESS CODE
							cyMy = yMinusxSlider + Dim.width;// To Test Moving Rainbow From Left To Right
						else cyMy = yMinusxSlider;// To Test Moving Rainbow From Left To Right*/

							/*radius = radialVariableDistance * 24 + colorDisplacement + 12 * angle;//14.4-1 For Hypnosis Spiral 24-12 For Shrunken. radialVariableDistance + colorDisplacement + angle;//Remove + angle And Add xSlider To Make Rainbow Clock
						while ( radius < colorDisplacement)//For Rainbow Ring
							radius = radius + fullAngle - colorDisplacement;//BAD COMMENT: For Rainbow Ring Take Out - 38
						while ( radius > fullAngle )
							radius = radius - fullAngle - colorDisplacement;
						if ( radius >= colorDisplacement && radius < 6 * colorInterval  + colorDisplacement)//For Purple Outside Ring
						{
							if ( radius < colorInterval  + colorDisplacement)//For Normal Rainbow Use This Instead Of The Others
								color.ColorSliderFunction(colorInterval, radius - colorDisplacement, red, orange);
							else if ( radius < ( 2 * colorInterval  + colorDisplacement) )
								color.ColorSliderFunction(colorInterval, radius - colorInterval - colorDisplacement, orange, yellow);
							else if ( radius < ( 3 * colorInterval  + colorDisplacement) )		
								color.ColorSliderFunction(colorInterval, radius - 2 * colorInterval - colorDisplacement, yellow, green);
							else if ( radius < ( 4 * colorInterval  + colorDisplacement) )
								color.ColorSliderFunction(colorInterval, radius - 3 * colorInterval - colorDisplacement, green, teal);
							else if ( radius < ( 5 * colorInterval  + colorDisplacement) )
								color.ColorSliderFunction(colorInterval, radius - 4 * colorInterval - colorDisplacement, teal, blue);
							else
								color.ColorSliderFunction(colorInterval, radius - 5 * colorInterval - colorDisplacement, blue, purple);
						}//*/
							/*if ( radius >= colorDisplacement && radius < 6 * colorInterval  + colorDisplacement)//For Purple Center Ring Make 6 * colorInterval Replaced With HalfedDim.height For Efficiency
						{
							if ( radius < colorInterval  + colorDisplacement)//For Normal Rainbow Use This Instead Of The Others
								color.ColorSliderFunction(colorInterval, radius - colorDisplacement, purple, blue);
							else if ( radius < ( 2 * colorInterval  + colorDisplacement) )
								color.ColorSliderFunction(colorInterval, radius - colorInterval - colorDisplacement, blue, teal);
							else if ( radius < ( 3 * colorInterval  + colorDisplacement) )		
								color.ColorSliderFunction(colorInterval, radius - 2 * colorInterval - colorDisplacement, teal, green);
							else if ( radius < ( 4 * colorInterval  + colorDisplacement) )
								color.ColorSliderFunction(colorInterval, radius - 3 * colorInterval - colorDisplacement, green, yellow);
							else if ( radius < ( 5 * colorInterval  + colorDisplacement) )
								color.ColorSliderFunction(colorInterval, radius - 4 * colorInterval - colorDisplacement, yellow, orange);
							else
								color.ColorSliderFunction(colorInterval, radius - 5 * colorInterval - colorDisplacement, orange, red);
						}//*/
							/*else
						{
							if ( radius < ( 7 * colorInterval ) )//For Normal Rainbow Use This Instead Of The Others
								color.ColorSliderFunction(colorInterval, radius - 6 * colorInterval, red, orange);
							else if ( radius < ( 8 * colorInterval ) )
								color.ColorSliderFunction(colorInterval, radius - 7 * colorInterval, orange, yellow);
							else if ( radius < ( 9 * colorInterval ) )		
								color.ColorSliderFunction(colorInterval, radius - 8 * colorInterval, yellow, green);
							else if ( radius < ( 10 * colorInterval ) )
								color.ColorSliderFunction(colorInterval, radius - 9 * colorInterval, green, teal);
							else if ( radius < ( 11 * colorInterval ) )
								color.ColorSliderFunction(colorInterval, radius - 10 * colorInterval, teal, blue);
							else
								color.ColorSliderFunction(colorInterval, radius - 11 * colorInterval, blue, purple);//*/
							//}
							//if (colorDisplacement <= radialDistance && radialDistance <= HalfedDim.height )//For Rainbow Disk And Ring Take Out 'Varible' Text Only I Think Only Needed Because Something Broken Which Is -37 On y For Statement

							//color.ColorSliderFunction(colorInterval, x, white, black);

							/*if ( xSlider <= colorInterval)//For Normal Rainbow Use This Instead Of The Others //Use For Fade-Ins And Fade-Outs
						color.ColorSliderFunction(colorInterval, xSlider, red, orange);
					else if ( xSlider <= 2 * colorInterval )
						color.ColorSliderFunction(colorInterval, xSlider - colorInterval, orange, yellow);
					else if ( xSlider <= 3 * colorInterval )		
						color.ColorSliderFunction(colorInterval, xSlider - 2 * colorInterval, yellow, green);
					else if ( xSlider <= 4 * colorInterval )
						color.ColorSliderFunction(colorInterval, xSlider - 3 * colorInterval, green, teal);
					else if ( xSlider <=  5 * colorInterval )
						color.ColorSliderFunction(colorInterval, xSlider - 4 * colorInterval, teal, blue);
					else if ( xSlider <=  6 * colorInterval )
						color.ColorSliderFunction(colorInterval, xSlider - 5 * colorInterval, blue, purple);
					else if ( xSlider <=  7 * colorInterval )
						color.ColorSliderFunction(colorInterval, xSlider - 6 * colorInterval, purple, red);//*/
							//int[] IntegerRGB = {new int[] (color.RGB[0]), color.RGB[1], color.RGB[2]};
							//for (int q = 0; q < (HalfedDim.width * 2) * (HalfedDim.height * 2) * 3; q = q + 3)//New Way For Fade-Ins And Fade-Outs And Circular Rainbow //Comment Out For Actual NonBackGround Changes In Pixels
							//{//Comment Out For Actual NonBackGround Changes In Pixels
							//}//Comment Out For Actual NonBackGround Changes In Pixels
							//wr.setPixels(0, 0, HalfedDim.width * 2 - 1, HalfedDim.height * 2 - 1, background);//New Way For Fade-Ins And Fade-Outs And Circular Rainbow
							/*for (x = 0; x < HalfedDim.width * 2; x++)//Old Way For Fade-Ins And Fade-Outs And Circular Rainbow
						for (y = 0; y < HalfedDim.height * 2; y++)//Use For Rainbow Slider
						{
							//f.repaint();
							wr.setPixel( x, y, color.RGB );//(double[])red.get()); //Use For Fade-Ins And Fade-Outs And This Command Makes Everything Change On The Actual Screen
						}//*/
							background[3 * x + Dim.width * 3 * y + 0] = (int)color.RGB[0];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 0]
							background[3 * x + Dim.width * 3 * y + 1] = (int)color.RGB[1];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 1]
							background[3 * x + Dim.width * 3 * y + 2] = (int)color.RGB[2];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 2]//*/
							wr.setPixel( x, y, color.RGB );//(double[])red.get()); //Use For Fade-Ins And Fade-Outs And This Command Makes Everything Change On The Actual Screen
							I.setRGB(x, y, (int)((int)color.RGB[0] * 65536 + (int)color.RGB[1] * 256 + (int)color.RGB[2]));//* //ASDF HERE HERE HERE HERE HERE
							//ASDFpw.setArgb( x, y, (int)(255 * 16777216 + (int)color.RGB[0] * 65536 + (int)color.RGB[1] * 256 + (int)color.RGB[2]));
						}//ASDF
					}//ASDF

					//wr.setPixels(0, 0, Dim.width, Dim.height, background);//wr.setPixels(0, 0, Dim.width + 1, Dim.height, background);//wr.setPixels(0, 0, HalfedDim.width * 2 + 1, HalfedDim.height * 2, background);//For NonUniform Background Colors
					//I.setData(wr);

					//f.invalidate();
					//f.revalidate();
					//f.repaint();
					/*
							label = new Label("My label");
							font = new Font("Techno Hideo", Font.PLAIN, 10);
							label.setFont( font );
							label.setHorizontalAlignment(SwingConstants.CENTER);
							label.setText(text);
							while ( label.getFontMetrics(font).stringWidth(text) <= Dim.width )
							{
								font = new Font("Techno Hideo", Font.PLAIN, font.getSize() + 1);
								label.setFont( font );
							}
							font = new Font("Techno Hideo", Font.PLAIN, font.getSize() - 10);
							label.setFont( font );

							label.revalidate();
							label.validate();
							label.repaint();
							label.setVisible(true);//*/

					//textWidth = label.getFontMetrics(font).stringWidth(text);
					xBlankSize = (Dim.width - textWidth) / 2;
					//yTextSize = label.getFontMetrics(font).getHeight();
					colorInterval2 = ( Dim.width - 2 * xBlankSize )/ ( numberOfColorsInTheRainbow - 1 );
					for (x = xBlankSize - 1; x < Dim.width - xBlankSize; x++)//x < HalfedDim.width * 2//For old Background Raster ( HalfedDim.width * 2 )// For Fractals And Rainbow Sliders And ??? ///To Test Moving Rainbow From Left To Right
					{
						for (y = 0; y < yTextSize; y++)//y < HalfedDim.height * 2//For old Background Raster ( HalfedDim.height * 2 )//Comment Out Here For NonFractals
						{

							tempColor = I.getRGB(x, y);
							tempBlue = tempColor & 0xff;
							tempGreen = (tempColor & 0xff00) >> 8;
						tempRed = (tempColor & 0xff0000) >> 16;
								testColor.set(new double[] {tempRed, tempGreen, tempBlue} );//ASDF HERE HERE HERE HERE HERE
								//System.out.println( testColor );
								if ( testColor.get() == black.get() );
								{
									radius = x - xBlankSize + 1 + xSlider;
									while ( radius < colorDisplacement)//For Rainbow Ring
										radius = radius + textWidth - colorDisplacement;
									if ( radius < colorInterval2  + colorDisplacement)//For Normal Rainbow Use This Instead Of The Others
										color.ColorSliderFunction(colorInterval2, radius - colorDisplacement, white, skyblue);
									else if ( radius < ( 2 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - colorInterval2 - colorDisplacement, skyblue, pink);
									else if ( radius < ( 3 * colorInterval2  + colorDisplacement) )		
										color.ColorSliderFunction(colorInterval2, radius - 2 * colorInterval2 - colorDisplacement, pink, blue);
									else if ( radius < ( 4 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 3 * colorInterval2 - colorDisplacement, blue, red);
									else if ( radius < ( 5 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 4 * colorInterval2 - colorDisplacement, red, purple);
									else if ( radius < ( 6 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 5 * colorInterval2 - colorDisplacement, purple, orange);
									else if ( radius < ( 7 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 6 * colorInterval2 - colorDisplacement, orange, green);
									else if ( radius < ( 8 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 7 * colorInterval2 - colorDisplacement, green, yellow);
									else if ( radius < ( 9 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 8 * colorInterval2 - colorDisplacement, yellow, teal);
									else if ( radius < ( 10 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 9 * colorInterval2 - colorDisplacement, teal, bronze);
									else if ( radius < ( 11 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 10 * colorInterval2 - colorDisplacement, bronze, silver);
									else if ( radius < ( 12 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 11 * colorInterval2 - colorDisplacement, silver, gold);
									else if ( radius < ( 13 * colorInterval2  + colorDisplacement) )
										color.ColorSliderFunction(colorInterval2, radius - 12 * colorInterval2 - colorDisplacement, gold, lime);
									else
										color.ColorSliderFunction(colorInterval2, radius - 13 * colorInterval2 - colorDisplacement, lime, brown);
								}
								y = y + Dim.height / 260;
								background[3 * x + Dim.width * 3 * y + 0] = (int)color.RGB[0];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 0]
								background[3 * x + Dim.width * 3 * y + 1] = (int)color.RGB[1];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 1]
								background[3 * x + Dim.width * 3 * y + 2] = (int)color.RGB[2];//background[3 * x + (HalfedDim.width * 6 + 3) * y + 2]//*/
								//ASDFpw.setArgb( x, y, (int)(255 * 16777216 + (int)color.RGB[0] * 65536 + (int)color.RGB[1] * 256 + (int)color.RGB[2]));
								wr.setPixel( x, y, color.RGB );//(double[])red.get()); //Use For Fade-Ins And Fade-Outs And This Command Makes Everything Change On The Actual Screen
								I.setRGB(x, y, (int)((int)color.RGB[0] * 65536 + (int)color.RGB[1] * 256 + (int)color.RGB[2]));
								y = y - Dim.height / 260;
						}
					}
					/*
							label.setVisible(false);
							label.revalidate();
							label.validate();
							label.repaint();//*/

					WritableImage wi = null;
					if (I != null) {
						wi = new WritableImage(I.getWidth(), I.getHeight());
						PixelWriter pw = wi.getPixelWriter();
						for (x = 0; x < I.getWidth(); x++) {
							for (y = 0; y < I.getHeight(); y++) {
								pw.setArgb(x, y, I.getRGB(x, y));
							}
						}
					}
					
					
					ImageView destImageView = new ImageView();
			        destImageView.setImage(wi);
			         
			        
			        vBox.getChildren().addAll(imageView, destImageView);
			 
			        //StackPane root = new StackPane();
			        stackPane.getChildren().add(vBox);
					
					
					imageView.setImage(wi);
					
					//Scene scene = new Scene(root, 300, 300);
			        //primaryStage.setTitle("java-buddy.blogspot.com");
			        primaryStage.setScene(scene);
					primaryStage.show();
					//image = wr.setPixels(0, 0, Dim.width, Dim.height, background);//wr.setPixels(0, 0, Dim.width + 1, Dim.height, background);//wr.setPixels(0, 0, HalfedDim.width * 2 + 1, HalfedDim.height * 2, background);//For NonUniform Background Colors
					//I.setData(wr);

					//f.add(label, BorderLayout.PAGE_START);

					/*if ( doneWritingFirstImage == false && xSlider == 0)
						{
							try{ ImageIO.write(I, "png", new File(selectedFile.getPath() ) ); Thread.sleep(100); }
							catch (Exception ex) {ex.printStackTrace();}
							doneWritingFirstImage = true;
							System.exit(0);
						}//*/
					if ( xSlider >= 0 )
					{
						//try{ enc.encodeImage(pw);
						//try{ enc.encodeImage(I);/* Thread.sleep(100); */}
						//catch (Exception ex) {ex.printStackTrace();}
					}
					//}//Comment Out This Line For No Primary NonSlider Loop.
					//System.out.println( xSlider );
					//System.out.println( (HalfedDim.width * 2 + 1) + " " + (HalfedDim.height * 2));
					//System.out.println( (HalfedDim.width * 2 + 1) + " " + (HalfedDim.height * 2));
					//System.out.println(selectedFile.getPath());
					//I = new BufferedImage(BufferedImage.TYPE_INT_RGB, wr, false, null);
					//wr = I.getRaster();
					//try{enc.encodeImage(wr.getPixels(0, 0, HalfedDim.width * 2, HalfedDim.height * 2, background));}
					/*try //Use This To Slow Down The Movement Of The xSlider
						{
							Thread.sleep(100);
						}
						catch (Exception ex)
						{
							ex.printStackTrace();
						}//*/
					//wr.wait(4000);
					//f.invalidate();
					//f.revalidate();
					//f.repaint();
					//wr.notify();
					xSlider = xSlider + interval;//For Hypnosis Sun
					//stage.show();
					//}
					//USE FOR xSlider for statement above
					/*for (x = 0; x < ( HalfedDim.width * 2 ); x++)// For Fractals And Rainbow Sliders And ??? ///To Test Moving Rainbow From Left To Right
						for (y = 0; y < ( HalfedDim.height * 2 ); y++)//Comment Out Here For NonFractals
							wr.setPixel(x, y, green.RGB);//DO NOT USE */

					//try{enc.finish();}
					//catch (Exception ex)
					//{ex.printStackTrace();}
					//System.exit(0);//*/
					//USE ABOVE FOR NEW CIRCULAR RAINBOWS


					//for (y = 0; y < Dim.height - 60; y++)//Comment Out Here For Rainbow Slider
					//{//Comment Out Here For Rainbow Slider
					//yMinusySlider = y - ySlider;//Comment Out Here For Rainbow Slider
					//yMinusySlider = y;//For Testing Only!
					//Comment Out Below For Rainbow Slider
					//if ( yMinusySlider < 0)// To Test Moving Rainbow From Left To Right //USE From HERE TILL else color.RGB = black.RGB; For Fractal
					//	cyMy = yMinusySlider + Dim.height;// To Test Moving Rainbow From Left To Right
					//else cyMy = yMinusySlider;// To Test Moving Rainbow From Left To Right
					/*if ( ( y - Dim.height / 2 ) != 0)// && y != 0
						{
							//a = - ( x - Dim.width / 2 ) / xSliderZoomFactor - ( y - 44 * xSlider - Dim.height / 2 ) * Dim.height / ( x - Dim.width / 2 ) * xSliderFactor / Dim.height;
							a = - ( y + 246 * xSliderBackAndFourth - Dim.height / 2 ) - ( x + 24 * xSliderBackAndFourth - Dim.width * 2 ) * Dim.width / ( y - Dim.height / 2 ) * xSliderFactor / Dim.width;
							while ( a < 0 )
								a = (int)(a + 6 * colorInterval);
							while ( a > 6 * colorInterval )
								a = (int)(a - 6 * colorInterval);
							if ( a < colorInterval )//For Normal Rainbow Use This Instead Of The Others
								color.ColorSliderFunction(colorInterval, a, red, orange);
							else if ( a < ( 2 * colorInterval ) )
								color.ColorSliderFunction(colorInterval, a - colorInterval, orange, yellow);
							else if ( a < ( 3 * colorInterval ) )		
								color.ColorSliderFunction(colorInterval, a - 2 * colorInterval, yellow, green);
							else if ( a < ( 4 * colorInterval ) )
								color.ColorSliderFunction(colorInterval, a - 3 * colorInterval, green, teal);
							else if ( a < ( 5 * colorInterval ) )
								color.ColorSliderFunction(colorInterval, a - 4 * colorInterval, teal, blue);
							else
								color.ColorSliderFunction(colorInterval, a - 5 * colorInterval, blue, purple);
						}
						else color.RGB = black.RGB;
						//wr.setPixel( x, y, color.RGB );//OLD WAY
					}
				//Comment Out Above For Rainbow Slider /*

				/*if ( cxMx < colorInterval ) // Cyberology - Ken Ishii Discography
					color.ColorSliderFunction(colorInterval, cxMx, yellow, blue);
  				else
  					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, blue, purple);//*/

					/*if ( cxMx < colorInterval ) // HealPacks - super furry animals - juxtaposed with u.mp3
					color.ColorSliderFunction(colorInterval, cxMx, yellow, red);
  				else
  					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, red, purple);//*/

					/*if ( cxMx < colorInterval ) // Sky Net - Paul Oakenfold - Essential Mix in China.mp3 + Paul Oakenfold - Miami Part 2.mp3    					color.ColorSliderFunction(colorInterval, cxMx, red, silver);
					color.ColorSliderFunction(colorInterval, cxMx, red, silver);
				else if ( cxMx < ( 2 * colorInterval ) )	
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, silver, gold);
				else		
					color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval, gold, blue);//*/

					//color.ColorSliderFunction(colorInterval, cxMx, green, purple);//Infinite Number Theorem

					/*if ( cxMx < colorInterval ) // Fountain of Youth
					color.ColorSliderFunction(colorInterval, cxMx, red, black);
				else
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, blue, purple);//*/



					/*if ( cxMx < colorInterval ) // Shill
					color.ColorSliderFunction(colorInterval, cxMx, red, black);
				else
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, black, red);//*/

					/*if ( cxMx < colorInterval ) // Grand Windmill
					color.ColorSliderFunction(colorInterval, cxMx, bronze, silver);
				else if ( cxMx < ( 2 * colorInterval ) )	
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, silver, gold);
				else		
					color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval, gold, black);//*/

					/*if ( cxMx < colorInterval ) // Poisonology
					color.ColorSliderFunction(colorInterval, cxMx, green, green);
				else if ( cxMx < ( 2 * colorInterval ) )	
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, green, blue);
				else if ( cxMx < ( 3 * colorInterval ) )	
					color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval, blue, green);
				else if ( cxMx < ( 4 * colorInterval ) )	
					color.ColorSliderFunction(colorInterval, cxMx - 3 * colorInterval, green, green);//*/

					/*if ( cxMx < colorInterval ) // Nuclear War
					color.ColorSliderFunction(colorInterval, cxMx, red, green);
				else if ( cxMx < ( 2 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, green, black);
				else if ( cxMx < ( 3 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval, black, white);
				else if ( cxMx < ( 4 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 3 * colorInterval, white, black);
				else if ( cxMx < ( 5 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 4 * colorInterval, black, green);
				else
					color.ColorSliderFunction(colorInterval, cxMx - 5 * colorInterval, green, red);//*/

					/*if ( cxMx < colorInterval ) // E-Democracy
					color.ColorSliderFunction(colorInterval, cxMx, green, gold);
				else if ( cxMx < ( 2 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, gold, red);
				else if ( cxMx < ( 3 * colorInterval ) )		
					color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval, red, purple);
				else if ( cxMx < ( 4 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 3 * colorInterval, purple, white);
				else if ( cxMx < ( 5 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 4 * colorInterval, white, black);
				else if ( cxMx < ( 6 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 5 * colorInterval, black, orange);
				else if ( cxMx < ( 7 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 6 * colorInterval, orange, yellow);
				else if ( cxMx < ( 8 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 7 * colorInterval, yellow, blue);
				else if ( cxMx < ( 9 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 8 * colorInterval, blue, silver);
				else if ( cxMx < ( 10 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 9 * colorInterval, silver, brown);
				else
					color.ColorSliderFunction(colorInterval, cxMx - 10 * colorInterval, brown, bronze);//*/





					/*if ( cxMx < colorInterval ) // Main Page - KMFDM +  + DJ Beck - Super Mix(feat.303Infinity,ATC,ATB,Alya,DJScott,BT,Prodigy,RobertMiles,PetShopBoys,Okenfold,DJ.mp3
					color.ColorSliderFunction(colorInterval, cxMx, red, green);
				else if ( cxMx < ( 2 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, green, blue);
				else		
					color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval, blue, red);//*/

					/*if ( cxMx < colorInterval ) // BAD!!! Main Page - KMFDM
					color.ColorSliderFunction(colorInterval, cxMx, red, bronze);
				else if ( cxMx < ( 2 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, bronze, silver);
				else if ( cxMx < ( 3 * colorInterval ) )		
					color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval, silver, gold);
				else if ( cxMx < ( 4 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 3 * colorInterval, gold, green);
				else if ( cxMx < ( 5 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 4 * colorInterval, green, green);
				else if ( cxMx < ( 6 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 5 * colorInterval, green, gold);
				else if ( cxMx < ( 7 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 6 * colorInterval, gold, silver);
				else if ( cxMx < ( 8 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 7 * colorInterval, silver, bronze);
				else if ( cxMx < ( 9 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - 8 * colorInterval, bronze, blue);
				else
					color.ColorSliderFunction(colorInterval, cxMx - 9 * colorInterval, blue, blue);//*/



					/*if ( cxMx < colorInterval ) // Jewlluminati History
					color.ColorSliderFunction(colorInterval, cxMx, blue, red);
				else
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, red, blue);//*/

					/*if ( cxMx < colorInterval ) // My Life Story
					color.ColorSliderFunction(colorInterval, cxMx, green, red);
				else
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, red, green);//*/



					/*if ( cxMx < colorInterval ) // Sky Command
					color.ColorSliderFunction(colorInterval, cxMx, red, orange);
				else if ( cxMx < ( 2 * colorInterval ) )
					color.ColorSliderFunction(colorInterval, cxMx - colorInterval, orange, yellow);
				else if ( cxMx < ( 3 * colorInterval ) )		
					color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval, yellow, lime);
				else
					color.ColorSliderFunction(colorInterval, cxMx - 3 * colorInterval, lime, green);//*/




					/*if ( cxMx < colorInterval )//For Normal Rainbow Use This Instead Of The Others
						color.ColorSliderFunction(colorInterval, cxMx, red, orange);
					else if ( cxMx < ( 2 * colorInterval ) )
						color.ColorSliderFunction(colorInterval, cxMx - colorInterval, orange, yellow);
					else if ( cxMx < ( 3 * colorInterval ) )		
						color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval, yellow, green);
					else if ( cxMx < ( 4 * colorInterval ) )
						color.ColorSliderFunction(colorInterval, cxMx - 3 * colorInterval, green, teal);
					else if ( cxMx < ( 5 * colorInterval ) )
						color.ColorSliderFunction(colorInterval, cxMx - 4 * colorInterval, teal, blue);
					else
						color.ColorSliderFunction(colorInterval, cxMx - 5 * colorInterval, blue, purple);//*/


					/*if ( cxMx <= ( 6 * colorInterval ) )
				{
					if ( cxMx < colorInterval )	
    					color.ColorSliderFunction(colorInterval, cxMx, 0.5, red, orange);
					else if ( cxMx < ( 2 * colorInterval ) )
						color.ColorSliderFunction(colorInterval, cxMx - colorInterval, 0.5, orange, yellow);
					else if ( cxMx < ( 3 * colorInterval ) )		
						color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval, 0.5, yellow, green);
					else if ( cxMx < ( 4 * colorInterval ) )
						color.ColorSliderFunction(colorInterval, cxMx - 3 * colorInterval, 0.5, green, teal);
    				else if ( cxMx < ( 5 * colorInterval ) )
    					color.ColorSliderFunction(colorInterval, cxMx - 4 * colorInterval, 0.5, teal, blue);
    				else
    					color.ColorSliderFunction(colorInterval, cxMx - 5 * colorInterval, 0.5, blue, purple);
				}
				else if ( cxMx <= ( 12 * colorInterval ) )
				{
					if ( cxMx < ( 7 * colorInterval ) )	
    					color.ColorSliderFunction(colorInterval, cxMx - 6 * colorInterval, red, orange);
					else if ( cxMx < ( 8 * colorInterval ) )
						color.ColorSliderFunction(colorInterval, cxMx - 7 * colorInterval, orange, yellow);
					else if ( cxMx < ( 9 * colorInterval ) )		
						color.ColorSliderFunction(colorInterval, cxMx - 8 * colorInterval, yellow, green);
					else if ( cxMx < ( 10 * colorInterval ) )
						color.ColorSliderFunction(colorInterval, cxMx - 9 * colorInterval, green, teal);
    				else if ( cxMx < ( 11 * colorInterval ) )
    					color.ColorSliderFunction(colorInterval, cxMx - 10 * colorInterval, teal, blue);
    				else
    					color.ColorSliderFunction(colorInterval, cxMx - 11 * colorInterval, blue, purple);
				}
				else
				{
					if ( cxMx < ( 13 * colorInterval ) )	
    					color.ColorSliderFunction(colorInterval, cxMx - 12 * colorInterval, 2, red, orange);
					else if ( cxMx < ( 14 * colorInterval ) )
						color.ColorSliderFunction(colorInterval, cxMx - 13 * colorInterval, 2, orange, yellow);
					else if ( cxMx < ( 15 * colorInterval ) )		
						color.ColorSliderFunction(colorInterval, cxMx - 14 * colorInterval, 2, yellow, green);
					else if ( cxMx < ( 16 * colorInterval ) )
						color.ColorSliderFunction(colorInterval, cxMx - 15 * colorInterval, 2, green, teal);
    				else if ( cxMx < ( 17 * colorInterval ) )
    					color.ColorSliderFunction(colorInterval, cxMx - 16 * colorInterval, 2, teal, blue);
    				else
    					color.ColorSliderFunction(colorInterval, cxMx - 17 * colorInterval, 2, blue, purple);
				}//*/

					//GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER!
					//GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER!
					//GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER!
					//GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER! GO HERE FOR RAINBOW SLIDER!
					//for (y = 0; y < Dim.height - 60; y++)//For Sideways Rainbow Works On My Machine.
					//	wr.setPixel( x, y, color.RGB );//(double[])red.get());

					//if (x < Dim.height) //For Diagonal Rainbow Works On My Machine.
					//	for (y = x; y >= 0; y--)
					//		wr.setPixel( x - y, y, color.RGB);
					//else
					//	for (y = Dim.height - 1; y >= 0; y--)
					//		wr.setPixel( x - y, y, color.RGB);//*/
					//colorInterval = colorInterval * 0.175979734764;//USE ONLY FOR VIACAD EMBLEM
					/*double colorDisplacement = 0;//cy * (1 - 0.175979734764);
				for (int r = 0; r <= cy; r++)//r = 346 Use Below For Circular RainbowFor Normal Rainbow Use This Instead Of The Other 3
				{
					cxMx = r - xSlider;//HERE HERE HERE WAS SLIDER
					//cxMx = r;//For NonMoving Rainbow
					if ( cxMx < 0)//346
						cxMx = cxMx + cy;
					//cxMx = (int)(cxMx + 0.175979734764 * cy);//Use For Ring

					//color.ColorSliderFunction(colorInterval, cxMx, green, purple);//Uncomment For Green Purple Circular Picture

					if ( cxMx <= ( 6 * colorInterval + colorDisplacement ) )
					{
						if ( cxMx < colorInterval + colorDisplacement )	
							color.ColorSliderFunction(colorInterval, cxMx - colorDisplacement, red, orange);
						else if ( cxMx < ( 2 * colorInterval + colorDisplacement ) )
							color.ColorSliderFunction(colorInterval, cxMx - colorInterval - colorDisplacement, orange, yellow);
							color.ColorSliderFunction(colorInterval, cxMx - 2 * colorInterval - colorDisplacement, yellow, green);
						else if ( cxMx < ( 4 * colorInterval + colorDisplacement ) )
							color.ColorSliderFunction(colorInterval, cxMx - 3 * colorInterval - colorDisplacement, green, teal);
						else if ( cxMx < ( 5 * colorInterval + colorDisplacement ) )
							color.ColorSliderFunction(colorInterval, cxMx - 4 * colorInterval - colorDisplacement, teal, blue);
						else
							color.ColorSliderFunction(colorInterval, cxMx - 5 * colorInterval - colorDisplacement, blue, purple);
					}//UnComment Below For Circular Rainbow*/
					/*totalAngleUnits = Math.round( ( r * ( 2 * Math.PI ) - 1 ) * Math.PI );//  * Math.PI  Seems To Be Wrong But Is Necessary With Math Inaccuracy!
					if ( r==0 )
						wr.setPixel(cx, cy, color.RGB);
					for (a = 0; a <= totalAngleUnits; a++)//a = angle interval so that all angles are included
					{
						wr.setPixel( (int)Math.round( cx + Math.cos( ( a/totalAngleUnits ) * 2 * Math.PI ) * r ),
								(int)Math.round( cy + Math.sin( ( a/totalAngleUnits ) * 2 * Math.PI ) * r ), color.RGB);
						//wr.setPixel( (int)Math.round( cx - Math.cos( ( a/totalAngleUnits ) * 2 * Math.PI ) * r ), (int)Math.round( cy + Math.sin( ( a/totalAngleUnits ) * 2 * Math.PI ) * r ), color.RGB);
						//wr.setPixel( (int)Math.round( cx + Math.cos( ( a/totalAngleUnits ) * 2 * Math.PI ) * r ), (int)Math.round( cy - Math.sin( ( a/totalAngleUnits ) * 2 * Math.PI ) * r ), color.RGB);
						//wr.setPixel( (int)Math.round( cx - Math.cos( ( a/totalAngleUnits ) * 2 * Math.PI ) * r ), (int)Math.round( cy - Math.sin( ( a/totalAngleUnits ) * 2 * Math.PI ) * r ), color.RGB);
					}// */
					//}//*///Comment Out Here For Rainbow Slider
					//}//Comment Out Here ?
					//}//Comment Out Here ?
					//wr.setPixel(x, y, color.RGB);
					//}//Use For Rainbow Slider Not Just Rainbow Pictures
					//f.invalidate();
					//f.revalidate();
					//f.repaint();
					//}
					//choice = 1;
					//}//Comment Out To Eliminate Sliding
				}
			}
			else if (choice == 1)
			{
				//Dim = f.getSize();

				//Thread.sleep(1000);
				choice = 2;
			}
			else if (choice == 2)
			{
				//Dim = f.getSize();

				//Thread.sleep(1000);
				choice = 4;
			}
		}
		//}//For selectedFile Check
	}


	
	
	
	//public Group root;
	//public Stage stage;

	/*public class MainGuiController implements Initializable
	{

		//***** @author n3wton

		//**** FXML declarations for MainGui.fxml
		@FXML
		private Pane main_top;
		@FXML
		private Button button1;

		//***** Beginning of auto-initialized method 
		@Override
		public void initialize(URL arg0, ResourceBundle arg1)
		{

		    button1.setPrefSize(1, 1);
		    main_top.setPrefSize(50, 10);
		}
	}//*/
	/*
	public class Controller implements Initializable {

	    @FXML private Canvas canvas ;

	    private GraphicsContext gc ;

	    @FXML private void drawCanvas(ActionEvent event) {
	        gc.setFill(Color.AQUA);
	        gc.fillRect(10,10,100,100);
	    }

	    @Override
	    public void initialize(URL location, ResourceBundle resources) {
	        gc = canvas.getGraphicsContext2D();
	        gc.setFill(Color.BLACK);
	        System.out.println("color set to black");
	        gc.fillRect(50, 50, 100, 100);
	        System.out.println("draw rectangle");
	    }

	}*/

	
	
	
	
	
	/*@Override
		public boolean isResizable() { return true; }

		@Override
		public double prefWidth(double height) { return getWidth(); }

		@Override
		public double prefHeight(double width) { return getHeight();}*/
}



/*  w ww .  j  av  a 2s.co m 
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javafx.application.Application;
import javafx.embed.swing.SwingFXUtils;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

import javax.imageio.ImageIO;

public class Main extends Application {
  public static void main(String[] args) {
    Application.launch(args);
  }

  @Override
  public void start(Stage stage) {
    String imagePath = "resources/picture/yourImage.jpg";
    Image image = new Image(imagePath);

    ImageView imageView = new ImageView(image);

    Button saveBtn = new Button("Save Image");
    saveBtn.setOnAction(e -> saveToFile(image));

    VBox root = new VBox(10, imageView, saveBtn);
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("");
    stage.show();
  }

  public static void saveToFile(Image image) {
    File outputFile = new File("C:/JavaFX/");
    BufferedImage bImage = SwingFXUtils.fromFXImage(image, null);
    try {
      ImageIO.write(bImage, "png", outputFile);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
}*/

