Sonnet With RainbowSystem Loop Seperate
package Sonnet;

import java.awt.Dimension;

import javafx.application.Application;

import java.awt.*;
import java.awt.image.*;
import java.awt.event.ActionEvent;
import java.awt.Dimension;
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.geometry.Rectangle2D;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.image.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelReader;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
import javafx.scene.input.KeyEvent;
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.*;

import java.util.Timer;
import java.util.TimerTask;

import org.jcodec.api.awt.SequenceEncoder;//Keep For .mp4 Video Creation

public class Sonnet extends Application
{

	@Override
	public void start(Stage stage)
	{
		//new Thread( () -> RainbowSystem(stage) ).start();
		RainbowSystem(stage);
	}


	//http://www.tutorialized.com/tutorial/JavaFX-2-Full-Screen-Scene/76585
	static void RainbowSystem(Stage primaryStage)
	{
		primaryStage.setTitle("Sonnet");
		primaryStage.setWidth(960);
		primaryStage.setHeight(540);

		// This is how you know how much screen you can write to.
		Screen screen = Screen.getPrimary();
		Rectangle2D bounds = screen.getVisualBounds();
		System.out.println(bounds);
		StackPane root = new StackPane();
		root.setPrefSize(960, 540);

		Dimension dimension = new Dimension( (int)bounds.getWidth(), (int)bounds.getHeight() );

		dimension.width = (int)bounds.getWidth();
		dimension.height = (int)bounds.getHeight() + 40;

		WritableImage writableImage = new WritableImage(dimension.width, dimension.height);
		//PixelWriter pixelWriter = writableImage.getPixelWriter();
		//WritableImage wi = new WritableImage(
		//		(int)primaryStage.getWidth(),
		//		(int)primaryStage.getHeight());
		PixelWriter pw = writableImage.getPixelWriter();
		PixelReader pr = writableImage.getPixelReader();

		Image image = new Image("http://www.nanofirm.org/KnightsOfTheSciMagOrder.png");
		ImageView imageView = new ImageView();
		ImageView waterMark = new ImageView();

		ColorSlider black = new ColorSlider( new double[]{0,0,0} );

		ColorSlider startColor = black;

		for (int x = 0; x < dimension.width; x++)
			for (int y = 0; y < dimension.height; y++)
				pw.setArgb( x, y, (int)(255 * 16777216 + (int)startColor.RGB[0] * 65536 + (int)startColor.RGB[1] * 256 + (int)startColor.RGB[2]));

		imageView.setImage(writableImage);
		waterMark.setImage(image);

		root.getChildren().add(imageView);
		root.getChildren().add(waterMark);
		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		primaryStage.setFullScreen(true);
		primaryStage.show();

		double slider = 0;
		try {// new Timer().schedule(new TimerTask() { public void run() {
		RainbowLoop(slider, pw, dimension);//, primaryStage);
		/*root.getChildren().removeAll(imageView);
		root.getChildren().removeAll(waterMark);
		root.getChildren().add(imageView);
		root.getChildren().add(waterMark);
		primaryStage.setScene(scene);
		primaryStage.show();*/
		//} }, 2000);}//
		Thread.sleep(2000);}
		catch (Exception ex) {ex.printStackTrace();}
		
		
		scene.setOnKeyReleased(new EventHandler<KeyEvent>()
		{
			@Override
			public void handle(KeyEvent event)
			{
				if ( event.isAltDown() == true)
				{
					switch (event.getCode())
					{
					case ENTER: primaryStage.setFullScreen(!primaryStage.isFullScreen()); break;
					}
				}
			}
		});
	}
	
	static void RainbowLoop (double xSlider, PixelWriter pixelWriter, Dimension Dim)//, Stage secondaryStage)
	{
		ColorSlider black = new ColorSlider( new double[]{0,0,0} );
		
		ColorSlider color = black;
		
		ColorSlider white = new ColorSlider( new double[]{255,255,255} );
		ColorSlider skyblue = new ColorSlider( new double[]{134,206,249} );
		ColorSlider pink = new ColorSlider( new double[]{255,64,143} );
		ColorSlider blue = new ColorSlider( new double[]{0,0,192} );
		ColorSlider red = new ColorSlider( new double[]{193,0,0} );
		ColorSlider purple = new ColorSlider( new double[]{122,0,178} );
		ColorSlider orange = new ColorSlider( new double[]{255,134,0} );
		ColorSlider green = new ColorSlider( new double[]{0,133,50} );
		ColorSlider yellow = new ColorSlider( new double[]{246,252,15} );
		ColorSlider teal = new ColorSlider( new double[]{3,224,149} );
		ColorSlider bronze = new ColorSlider( new double[]{152,123,46} );
		ColorSlider silver = new ColorSlider( new double[]{193,192,192} );
		ColorSlider gold = new ColorSlider( new double[]{205,191,44} );
		ColorSlider lime = new ColorSlider( new double[]{126,193,33} );
		ColorSlider brown = new ColorSlider( new double[]{131,103,71} );

		int numberOfColorsInTheRainbow = 15;//asdf Always Worry About This!

		//int [] background = {255, 255, 255};
		//background = new int[Dim.width * Dim.height * 3];
		Dimension HalfedDim = new Dimension(Dim.width / 2, Dim.height / 2);
		//HalfedDim.width = Math.round( Dim.width / 2 );
		//HalfedDim.height = Math.round( Dim.height / 2 );
		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;
		double angle = 0;
		double a = 0;
		double radius = 0;
		double colorDisplacement = 0;

		double interval = fullAngle / 10 / 111;//Last Division Determines The Frame Rate

		double colorInterval = fullAngle / ( numberOfColorsInTheRainbow - 1 );//For Rainbow Clock And Spiral
		
		while (xSlider < fullAngle / 10)
		{
			for (int 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 (int 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]//*/
					pixelWriter.setArgb( x, y, (int)(255 * 16777216 + (int)color.RGB[0] * 65536 + (int)color.RGB[1] * 256 + (int)color.RGB[2]));//setArgb
				}
			}
			xSlider = xSlider + interval;
			System.out.println(Dim);
		}
		return;
	}

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