package rainbowPackage;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;

import javax.imageio.ImageIO;

import java.io.*;

import org.jcodec.api.SequenceEncoder;
import org.jcodec.api.SequenceEncoder.*;

import org.jcodec.api.awt.AWTSequenceEncoder;
import org.jcodec.api.awt.*;
import org.jcodec.api.awt.AWTSequenceEncoder.*;

import org.jcodec.common.Codec;
import org.jcodec.common.Format;
import org.jcodec.common.io.NIOUtils;
import org.jcodec.common.io.SeekableByteChannel;
import org.jcodec.common.model.Rational;
import org.jcodec.scale.AWTUtil;
import org.jcodec.api.*;
import java.nio.channels.*;
//import java.nio.channels.SeekableByteChannel;
import org.jcodec.*;//Keep For .mp4 Video Creation

import java.awt.*;
import java.awt.image.*;

import javafx.embed.swing.SwingFXUtils;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.*;
import javafx.scene.image.*;
import javafx.scene.image.Image;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Screen;
import javafx.stage.Stage;
import rainbowPackage.RainbowSoftColorCodesSets.BuddhismSchemeSet;

public class RainbowVideo
{
	double sliderInterval = 100;
	Diagnostics diagnostics = null;
	RainbowSoftColor color = new RainbowSoftColor( new double[]{0,0,0,1} );//????????????????????????????
	RainbowPattern2D pattern2D = new RainbowPattern2D( new double[]{0,0,0,1} );
	RainbowSoft2D rainbowSoft2D = new RainbowSoft2D( new double[]{0,0,0,1} );
	TransparencySlider transparencySlider = new TransparencySlider( new double[]{0,0,0,1} );
	RainbowSoftColor rainbowSoftColor = new RainbowSoftColor( new double[]{0,0,0,1} );
	Color tempFXColor = Color.BLACK;
	BufferedImage bImage = null;
	AWTSequenceEncoder encoder;
	Stage tertiaryStage;
	Image tertiaryBasisImage;
	Image tertiaryBackgroundBasisImage;
	WebEngine thirdBrowserEngine;
	WebView thirdBrowser;
	StackPane thirdStackPane[];
	Scene thirdScene[];
	Screen thirdScreen;
	Label thirdStateLabel;
	File thirdFile;
	File thirdJavaScriptFile;
	File thirdXSliderFile;
	Thread tertiaryThread;
	boolean tertiaryIsFullScreened;
	Image tertiaryBackupWorkAroundImage;
	double tertiaryXslider = 0;
	double videoFrameQuantity = 7;
	double startingPoint = 0;
	double videoSequenceLoopQuantity;
	double numberOfScrollFrames;
	SeekableByteChannel tertiaryVideoOut;

	WritableImage tertiaryWritableImage;
	PixelWriter tertiaryPW;
	ImageView tertiaryImageView;
	Image tertiaryCurrentBrowserImage;
	WritableImage tertiaryBufferPicture;
	
	public RainbowVideo ( Stage TertiaryStage, Image TertiaryBasisImage, Image TertiaryBackgroundBasisImage, WebEngine ThirdBrowserEngine, WebView ThirdBrowser, StackPane ThirdStackPane[], Scene ThirdScene[], Screen ThirdScreen,
			Label ThirdStateLabel, File ThirdFile, File ThirdJavaScriptFile, File ThirdXSliderFile, Thread TertiaryThread, boolean TertiaryIsFullScreened,
			Image TertiaryBackupWorkAroundImage, double VideoFrameQuantity, double StartingPoint, double VideoSequenceLoopQuantity, SeekableByteChannel TertiaryVideoOut, WritableImage TertiaryWritableImage,
			PixelWriter TertiaryPW, ImageView TertiaryImageView, Image TertiaryCurrentBrowserImage, WritableImage TertiaryBufferPicture, double NumberOfScrollFrames )
	{
		tertiaryStage = TertiaryStage;
		tertiaryBasisImage = TertiaryBasisImage;
		tertiaryBackgroundBasisImage = TertiaryBackgroundBasisImage;
		thirdBrowserEngine = ThirdBrowserEngine;
		thirdBrowser = ThirdBrowser;
		thirdStackPane = ThirdStackPane;
		thirdScene = ThirdScene;
		thirdScreen = ThirdScreen;
		thirdStateLabel = ThirdStateLabel;
		thirdFile = ThirdFile;
		thirdJavaScriptFile = ThirdJavaScriptFile;
		thirdXSliderFile = ThirdXSliderFile;
		tertiaryThread = TertiaryThread;
		tertiaryIsFullScreened = TertiaryIsFullScreened;
		tertiaryBackupWorkAroundImage = TertiaryBackupWorkAroundImage;
		videoFrameQuantity = VideoFrameQuantity;
		startingPoint = StartingPoint;
		videoSequenceLoopQuantity = VideoSequenceLoopQuantity;
		tertiaryVideoOut = TertiaryVideoOut;

		tertiaryWritableImage = TertiaryWritableImage;
		tertiaryPW = TertiaryPW;
		tertiaryImageView = TertiaryImageView;
		tertiaryCurrentBrowserImage = TertiaryCurrentBrowserImage;
		tertiaryBufferPicture = TertiaryBufferPicture;
		
		numberOfScrollFrames = NumberOfScrollFrames;
		
		Diagnostics diagnostics = new Diagnostics( thirdScreen.getBounds() );

		sliderInterval = videoSequenceLoopQuantity / videoFrameQuantity;
		try { tertiaryVideoOut = NIOUtils.writableFileChannel( thirdFile.getPath() ); }
		catch (IOException e) {}

	}

	public BufferedImage Runner ()
	{		
		bImage = null;
		//try { encoder = new AWTSequenceEncoder(tertiaryVideoOut, Rational.R(25, 1));}
		//catch(IOException ie) { ie.printStackTrace(); }
		try { encoder = AWTSequenceEncoder.create25Fps(thirdFile);}
		catch(IOException ie) { ie.printStackTrace(); }
		
		//tertiaryStage.setFullScreen(tertiaryIsFullScreened);
		//tertiaryStage.setScene(thirdScene[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity )]);
		//tertiaryStage.setFullScreen(tertiaryIsFullScreened);
		if ( tertiaryIsFullScreened == false )
		{
			tertiaryStage.setWidth(666);
			tertiaryStage.setHeight(888);
			tertiaryStage.setFullScreen(false);
			tertiaryStage.show();
		}
		System.out.println("Worked Till After Full Screen Enforcement");
		Dimension HalfedDim = new Dimension( 960, 540 );
		Dimension Dim = new Dimension ( (int)tertiaryStage.getWidth() - 40, (int)tertiaryStage.getHeight() - 40 );
		HalfedDim.width = Math.round( (int)tertiaryStage.getWidth() / 2 );
		HalfedDim.height = Math.round( (int)tertiaryStage.getHeight() / 2 );
		//Dimension Dim = new Dimension ( (int)thirdScreen.getBounds().getWidth() , (int)thirdScreen.getBounds().getHeight() - 40 );
		//HalfedDim.width = Math.round( (int)thirdScreen.getBounds().getWidth() / 2 );
		//HalfedDim.height = Math.round( (int)thirdScreen.getBounds().getHeight() / 2 );
		double halfSreenDiagionalLength = Math.pow(Math.pow( HalfedDim.getWidth(), 2) + Math.pow( HalfedDim.getHeight(), 2), 0.5);
		
		int x = 0, y = 0;
		
		PixelReader origionalpr = tertiaryCurrentBrowserImage.getPixelReader(), basispr = tertiaryBasisImage.getPixelReader(), backgroundbasispr = tertiaryBackgroundBasisImage.getPixelReader();;
		//"FullDisplay", "BackgroundToBasisFullDisplay", "FullDisplayNoTextShownAtAll", "FullDisplayBasisText", "FullDisplayBackgroundToBasisNoTextShownAtAll", "BackgroundToBasisFullDisplayBasisText", "FullDisplayBasisBackround", "FullDisplayBackroundToBasis", "FullDisplayBasisOnly", "FullDisplayBackroundToBasisOnly", "BasisBackroundDisplayOnly", "BackroundToBasisOnly", "TextDisplayOnly", "BasisTextDisplayOnly", "BasisTextDisplayOnWhite", "BasisTextDisplayOnBlack", "NoDisplay", "BlackScreen"
		String typeOfDisplay = "FullDisplay";//"BasisTextDisplayOnWhite";//"BasisTextDisplayOnly";//"FullDisplay";//
		boolean invertBasisFromBackground = true, reversalOfBackgroundEffectsMaster = true, nextStepColorTooSimilarEffect = false;
		Color initialColorContrastingChoice = VibrantColors.NeonGreen.ToFXColor(), colorTooSimilarReplacementColor = VibrantColors.SkyBlue.ToFXColor();
		double colorDifference = 164;
		int lengthOfColorBar = 0;
		TransparencySlider buddhismBlackBlue0 = new TransparencySlider( new double [] {0., 0., 1., 1.} );
		for (x = 0; x < Dim.width; x++)
			if ( basispr.getColor( x, HalfedDim.height ).getOpacity() == buddhismBlackBlue0.ToFXColor().getOpacity() &&
			 	 basispr.getColor( x, HalfedDim.height ).getRed() == buddhismBlackBlue0.ToFXColor().getRed() &&
			 	 basispr.getColor( x, HalfedDim.height ).getGreen() == buddhismBlackBlue0.ToFXColor().getGreen() &&
			 	 basispr.getColor( x, HalfedDim.height ).getBlue() == buddhismBlackBlue0.ToFXColor().getBlue() )
				lengthOfColorBar++;
		System.out.println("lengthOfColorBar: " + lengthOfColorBar);
		tertiaryXslider = 0;
		System.out.println("tertiaryXslider: " + tertiaryXslider);
		//tertiaryXslider = 3301.2077096635903;//FOR TESTING END ANOMOLYS ONLY
		while ( tertiaryXslider < videoSequenceLoopQuantity )//fullScrollCycle / 4000 )// For Scrolling; tertiaryXslider < fullScrollCycle / 4000 . For MagiElite: videoSequenceLoopQuantity / 10)//for (tertiaryXslider = 0; tertiaryXslider <= 0.175979734764 * cy; tertiaryXslider++)
		{//0.175979734764 *
			tertiaryStage.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>()
			{
				@Override
				public void handle(MouseEvent event) 
				{
					System.exit(0);
				}
			});
			try { tertiaryThread.sleep(44);
			} catch (InterruptedException e) {
				System.out.println("Interrupted.");
			}

			System.out.println("Worked Till After 0.044 s third Wait");
			tertiaryStage.setScene(thirdScene[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity )]);

			System.out.println("Got To Primary for Statement");
			for (x = 0; x < Dim.width; x++) //Dim.width; x++)//Comment Out Here For Circular Rainbow
			{
				for (y = 0; y < Dim.height; y++)
				{					
					//diagnostics.ColorTooSimilar( x, y, tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity );
					//diagnostics.ColorSlider( x, y, tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity, tertiaryXslider / videoSequenceLoopQuantity, (int)( tertiaryXslider / sliderInterval ) );
					//diagnostics.TransparencySlider( x, y, tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity, tertiaryXslider / videoSequenceLoopQuantity, (int)( tertiaryXslider / sliderInterval ), 0, 1 );
					//diagnostics.RainbowSoftColor( x, y, tertiaryXslider, tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity, (int)( tertiaryXslider / sliderInterval ), VibrantColorCombos.ImperialFXcolors, VibrantColorCombos.ImperialColorsNum, 0, 1 );
					//4444
					//LocationOfStillMovement & LocationOfColorMovement MUST BE SYNCED!!!!!!!!
					//pattern2D.SimpleCustomColor( thirdScreen.getBounds().getWidth() / imperialFXcolors.length, 0., tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity,  x - HalfedDim.width, thirdScreen.getBounds().getWidth() / 2., imperialFXcolors );

					//pattern2D.SimpleRainbow( thirdScreen.getBounds().getWidth(), 0., tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity,  x, thirdScreen.getBounds().getWidth() );
					//pattern2D.SimpleRainbow( thirdScreen.getBounds().getWidth(), 0., 12. * tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity,  x, thirdScreen.getBounds().getWidth() / 6. );
					//pattern2D.SimpleRainbow( thirdScreen.getBounds().getWidth() / 3., 0., tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity,  x, thirdScreen.getBounds().getWidth() );
					//pattern2D.SimpleRainbow( - thirdScreen.getBounds().getWidth(), 0., tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity,  x, - thirdScreen.getBounds().getWidth() );
					//pattern2D.SimpleRainbow( - thirdScreen.getBounds().getWidth(), 0., tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity,  x, thirdScreen.getBounds().getWidth() );
					//pattern2D.SimpleRainbow( thirdScreen.getBounds().getWidth(), 0., tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity,  x, - thirdScreen.getBounds().getWidth() );

					//pattern2D.SimpleRainbow( - thirdScreen.getBounds().getWidth(), 0, 12 * tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity, x, thirdScreen.getBounds().getWidth() / 6. );
					//pattern2D.SimpleRainbow( - thirdScreen.getBounds().getWidth(), 0, 12. * tertiaryXslider * thirdScreen.getBounds().getWidth() / videoSequenceLoopQuantity, x, - thirdScreen.getBounds().getWidth() / 6. );

					//Screen Bounds Not In Alignment Yet Because Not Full Screened
					//pattern2D.RainbowDiskVaryated( thirdScreen.getBounds().getHeight() / 4., 0, tertiaryXslider * thirdScreen.getBounds().getHeight() / videoSequenceLoopQuantity / 4.,  x - HalfedDim.width, y - HalfedDim.height, thirdScreen.getBounds().getHeight() / 4., false );
					//pattern2D.RainbowDiskVaryated( thirdScreen.getBounds().getHeight() / 4., 0, tertiaryXslider * thirdScreen.getBounds().getHeight() / videoSequenceLoopQuantity / 4.,  x - HalfedDim.width, y - HalfedDim.height, thirdScreen.getBounds().getHeight() / 24., false );
					//pattern2D.RainbowDiskVaryated( thirdScreen.getBounds().getHeight() / 12., 0, tertiaryXslider * thirdScreen.getBounds().getHeight() / videoSequenceLoopQuantity / 4.,  x - HalfedDim.width, y - HalfedDim.height, thirdScreen.getBounds().getHeight() / 4., false );

					//pattern2D.SimpleRainbow( thirdScreen.getBounds().getWidth() / 7, 0, tertiaryXslider * thirdScreen.getBounds().getHeight() / videoSequenceLoopQuantity,  x - HalfedDim.width, thirdScreen.getBounds().getWidth() / 2 );// - Locaition Flips Rainbow Like Reverse Without Green Being Replaced By Pink
					//BuildMepattern2D.RainbowDiskVaryated( thirdScreen.getBounds().getHeight() / 7, 0, tertiaryXslider * thirdScreen.getBounds().getHeight() / videoSequenceLoopQuantity / 2,  x - HalfedDim.width, y - HalfedDim.height, thirdScreen.getBounds().getHeight() / 2, false );//May Not Be Synced Properly To Show 1 Clock Rotation Must Be Properly Relative Factoring
					//pattern2D.RainbowDiskVaryated( thirdScreen.getBounds().getHeight() / 7, 0, tertiaryXslider * thirdScreen.getBounds().getHeight() / videoSequenceLoopQuantity / 2,  x - HalfedDim.width, y - HalfedDim.height, thirdScreen.getBounds().getHeight() / 2, false );//May Not Be Synced Properly To Show 1 Clock Rotation Must Be Properly Relative Factoring
					//pattern2D.RainbowDiskVaryated( thirdScreen.getBounds().getHeight() / 14, 0, tertiaryXslider * thirdScreen.getBounds().getHeight() / videoSequenceLoopQuantity / 2 ,  x - HalfedDim.width, y - HalfedDim.height, thirdScreen.getBounds().getHeight() / 14, false );//May Not Be Synced Properly To Show 1 Clock Rotation Must Be Properly Relative Factoring

					//pattern2D.RainbowDiskVaryated( thirdScreen.getBounds().getHeight() / 4., 0, tertiaryXslider * thirdScreen.getBounds().getHeight() / videoSequenceLoopQuantity / 4.,  x - HalfedDim.width, y - HalfedDim.height, thirdScreen.getBounds().getHeight() / 4., VibrantColorCombos.ImperialFXcolors, false );
					//pattern2D.RainbowDiskVaryated( thirdScreen.getBounds().getHeight() / 4., 0, tertiaryXslider * thirdScreen.getBounds().getHeight() / videoSequenceLoopQuantity / 4.,  x - HalfedDim.width, y - HalfedDim.height, thirdScreen.getBounds().getHeight() / 4., VibrantColorCombos.HalloweenFXcolors, false );

					//pattern2D.RainbowClockVaryated( videoSequenceLoopQuantity / 2., 0, tertiaryXslider * videoSequenceLoopQuantity * 4,  x - HalfedDim.width, y - HalfedDim.height, videoSequenceLoopQuantity / 2., false );
					//pattern2D.RainbowClockVaryated( videoSequenceLoopQuantity / 2., 0, tertiaryXslider * videoSequenceLoopQuantity * 4,  x - HalfedDim.width, y - HalfedDim.height, videoSequenceLoopQuantity / 2., halfSreenDiagionalLength, false );
					//pattern2D.RainbowClockVaryated( Math.PI / 2., Math.PI * - tertiaryXslider / videoSequenceLoopQuantity + Math.PI, 0, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2., false );
					//pattern2D.RainbowClockVaryated( Math.PI / 2., Math.PI * - tertiaryXslider / videoSequenceLoopQuantity + Math.PI, - 2. * tertiaryXslider / videoSequenceLoopQuantity, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2., false );

					//pattern2D.RainbowClockVaryated( Math.PI / 2.5, 0, - ( 12. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5. + 3 * Math.PI / 15, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 15., false );//MUST BE RADIALLY SYNCED
					//pattern2D.RainbowClockVaryated( Math.PI / 7.5, 0, - ( 4. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5. + 7.5 * Math.PI / 7.5, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2.5, false );
					//pattern2D.RainbowClockVaryated( Math.PI / 2.5, - ( 12. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5. + 3 * Math.PI / 15, 0, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 15., false );//MUST BE RADIALLY SYNCED
					//pattern2D.RainbowClockVaryated( Math.PI / 7.5, - ( 4. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5. + 7.5 * Math.PI / 7.5, 0, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2.5, false );
					//SYNC Loc RADIALLY LIKEABOVE With LocOColMv//pattern2D.RainbowClockVaryated( Math.PI / 2.5, ( 12. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5. + Math.PI, ( 6. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5., x - HalfedDim.width, y - HalfedDim.height, Math.PI / 15., false );
					//pattern2D.RainbowClockVaryated( Math.PI / 7.5, ( 4. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5. + Math.PI, - ( 3.5 * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5., x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2.5, false );

					//1st Check Over All 36 Functions To Check To Make Sure They Will Acesess The Right Function In The End

					//Tests For All SliderFormulates In RainbowPattern2D
					//MovingColors
					//pattern2D.RainbowClockVaryated( Math.PI / 2., 0, Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2., x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2., false );//1
					//pattern2D.RainbowClockVaryated( Math.PI / 2.5, 0, 12. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 2.5, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 15., false );//2//!!!!!{Potential BUG Caused By Patent Terrorists Here}?LocationOfColorMovement Must Be - For Rainbow Clock To Work Properly As A Natural Consequence Of Things
					//pattern2D.RainbowClockVaryated( Math.PI / 7.5, 0, Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 2.5, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2.5, false );//3
					//MovingColors Negatives
					//pattern2D.RainbowClockVaryated( - Math.PI / 2., 0, Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2., x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2., false );//4//Remember 2 * 180 degrees, 2 * Math.PI So Half The Divisor And Add Math.PI To Location To Make Into Clock Make tertiaryXslider -tertiaryXslider To Reverse Spinning Direction
					//pattern2D.RainbowClockVaryated( - Math.PI / 2., 0, Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2., x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2., false );//5
					//pattern2D.RainbowClockVaryated( Math.PI / 2., 0, Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2., x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2., false );//6
					//pattern2D.RainbowClockVaryated( - Math.PI / 2.5, 0, 12. * Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5, x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 15., false );//7
					//pattern2D.RainbowClockVaryated( - Math.PI / 2.5, 0, 12. * Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 15., false );//8
					//pattern2D.RainbowClockVaryated( Math.PI / 2.5, 0, 12. * Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5, x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 15., false );//9
					//pattern2D.RainbowClockVaryated( - Math.PI / 7.5, 0, Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5,  x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2.5, false );//10
					//pattern2D.RainbowClockVaryated( - Math.PI / 7.5, 0, Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5,  x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2.5, false );//11
					//pattern2D.RainbowClockVaryated( Math.PI / 7.5, 0, Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5, x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2.5, false );//12
					//TransitionSlider
					//pattern2D.RainbowClockVaryated( Math.PI / 2., Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2., 0, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2., false );//13 //Does Something Slightly Different Than Expected That May Become Something New But NM I Think It Is Doing What Is Supposed To Do But Save Things When You Get It Back To This Or This When You Get This To That.
					//pattern2D.RainbowClockVaryated( Math.PI / 2.5, 12. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 2.5, 0, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 15., false );//14
					//pattern2D.RainbowClockVaryated( Math.PI / 7.5, Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 2.5 + 7.5 * Math.PI / 7.5, 0, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2.5, false );//15

					//After Doing 3 Main DoubleSliders Stop Here And Wait For Diagnostics [9 ++] 3X[-~-] To Test!!

					//TransitionSlider Negatives
					//pattern2D.RainbowClockVaryated( - Math.PI / 2., Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2, 0, x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2., false );//16
					//pattern2D.RainbowClockVaryated( - Math.PI / 2., Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2, 0, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2., false );//17
					//pattern2D.RainbowClockVaryated( Math.PI / 2., Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2, 0, x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2., false );//18
					//pattern2D.RainbowClockVaryated( - Math.PI / 2.5, 12. * Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5, 0, x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 15., false );//19
					//pattern2D.RainbowClockVaryated( - Math.PI / 2.5, 12. * Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5, 0, x - HalfedDim.width, y - HalfedDim.height, Math.PI / 15., false );//20
					//pattern2D.RainbowClockVaryated( Math.PI / 2.5, 12. * Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5, 0, x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 15., false );//21
					//pattern2D.RainbowClockVaryated( - Math.PI / 7.5, Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5, 0,  x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2.5, false );//22
					//pattern2D.RainbowClockVaryated( - Math.PI / 7.5, Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5, 0,  x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2.5., false );//23
					//pattern2D.RainbowClockVaryated( Math.PI / 7.5, Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2.5, 0, x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2.5, false );//24
					//DoubleSlider
					//pattern2D.RainbowClockVaryated( Math.PI / 2., Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2., - Math.PI * ( - tertiaryXslider / videoSequenceLoopQuantity ) / 2., x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2., false );//25 //Save Any Changes To Under Functions To Preserve These Beauties
					//pattern2D.RainbowClockVaryated( Math.PI / 2.5, - 6. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 5., ( 12. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5., x - HalfedDim.width, y - HalfedDim.height, Math.PI / 15., false );//26
					//pattern2D.RainbowClockVaryated( Math.PI / 7.5, 3. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 5., ( 4. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5., x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2.5, false );//27
					//DoubleSlider Negatives
					//pattern2D.RainbowClockVaryated( - Math.PI / 2., Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2., - Math.PI * ( - tertiaryXslider / videoSequenceLoopQuantity ) / 2., x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2., false );//28
					//pattern2D.RainbowClockVaryated( - Math.PI / 2., Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2., - Math.PI * ( - tertiaryXslider / videoSequenceLoopQuantity ) / 2., x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2., false );//29
					//pattern2D.RainbowClockVaryated( Math.PI / 2., Math.PI * ( tertiaryXslider / videoSequenceLoopQuantity ) / 2., - Math.PI * ( - tertiaryXslider / videoSequenceLoopQuantity ) / 2., x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2., false );//30
					//pattern2D.RainbowClockVaryated( - Math.PI / 2.5, - 6. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 5., ( 12. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5., x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 15., false );//31
					//pattern2D.RainbowClockVaryated( - Math.PI / 2.5, - 6. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 5., ( 12. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5., x - HalfedDim.width, y - HalfedDim.height, Math.PI / 15., false );//32
					//pattern2D.RainbowClockVaryated( Math.PI / 2.5, - 6. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 5., ( 12. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5., x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 15., false );//33
					//pattern2D.RainbowClockVaryated( - Math.PI / 7.5, 3. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 5., ( 4. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5., x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2.5, false );//34
					//pattern2D.RainbowClockVaryated( - Math.PI / 7.5, 3. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 5., ( 4. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5., x - HalfedDim.width, y - HalfedDim.height, Math.PI / 2.5., false );//35
					//pattern2D.RainbowClockVaryated( Math.PI / 7.5, 3. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity / 5., ( 4. * Math.PI * tertiaryXslider / videoSequenceLoopQuantity ) / 5., x - HalfedDim.width, y - HalfedDim.height, - Math.PI / 2.5, false );//36

					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity, 0, tertiaryXslider, ( x - HalfedDim.width ) / 3., ( y - HalfedDim.height ) / 3., videoSequenceLoopQuantity, 24.6, 1., halfSreenDiagionalLength, false );
					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity / 3, tertiaryXslider, -tertiaryXslider, ( x - HalfedDim.width ) / 3., ( y - HalfedDim.height ) / 3., videoSequenceLoopQuantity, 24.6, 1., halfSreenDiagionalLength, false );
					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity, 6 * tertiaryXslider, -6 * tertiaryXslider, ( x - HalfedDim.width ) / 3., ( y - HalfedDim.height ) / 3., videoSequenceLoopQuantity / 6, 24.6, 1., halfSreenDiagionalLength, false );

					//BAD pattern2D.RainbowClockVaryated( 90, 0, - tertiaryXslider * 360 / videoSequenceLoopQuantity,  x - HalfedDim.width, y - HalfedDim.height, 90, 3, 180, false );//BAD
					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity, 0, tertiaryXslider, ( x - HalfedDim.width ) / 3., ( y - HalfedDim.height ) / 3., videoSequenceLoopQuantity, 24.6, 1, halfSreenDiagionalLength, false );//For Proper Rainbow Hypnosis Spiral
					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity, 0, tertiaryXslider, ( x - HalfedDim.width ) / 10., ( y - HalfedDim.height ) / 10., videoSequenceLoopQuantity, 144, 10, halfSreenDiagionalLength, false );//For Proper Rainbow Rainbow Shrunken
					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity * 6, 0, tertiaryXslider * 6, ( x - HalfedDim.width ) / 6., ( y - HalfedDim.height ) / 6., videoSequenceLoopQuantity, 88.8, 4, halfSreenDiagionalLength, false );//For Segment View
					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity, 0, tertiaryXslider * 3, ( x - HalfedDim.width ) / 6., ( y - HalfedDim.height ) / 6., videoSequenceLoopQuantity * 3, 66.6, 3, halfSreenDiagionalLength, false );//For View Of More Length Than 1 Segment, Values Must Be Mulitples Of Eachother Somehow 3 In This Instance
					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity, 0, tertiaryXslider, ( x - HalfedDim.width ) / 1., ( y - HalfedDim.height ) / 1., videoSequenceLoopQuantity, 999, 1680, halfSreenDiagionalLength, false );//For Proper Rainbow PsychaHypnotic
					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity, 0, tertiaryXslider, ( x - HalfedDim.width ) / 10., ( y - HalfedDim.height ) / 10., videoSequenceLoopQuantity, 999, 1680, halfSreenDiagionalLength, false );//For Strange Rainbow PsychaHypnotic

					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity, tertiaryXslider * 3, tertiaryXslider * 3, ( x - HalfedDim.width ) / 6., ( y - HalfedDim.height ) / 6., videoSequenceLoopQuantity * 3, 66.6, 3, halfSreenDiagionalLength, false );
					///pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity, tertiaryXslider * 6., tertiaryXslider * 6., ( x - HalfedDim.width ) / 6., ( y - HalfedDim.height ) / 6., videoSequenceLoopQuantity / 6., 66.6, 3, halfSreenDiagionalLength, false );

					//System.out.println("x: " + x +" y: " + y + " tertiaryXslider: " + tertiaryXslider);
					//pattern2D.RainbowSpiralVaryated( videoSequenceLoopQuantity, 0, tertiaryXslider / Math.pow ( 1.003, tertiaryXslider ), ( x - HalfedDim.width ) / Math.pow( 1.004, tertiaryXslider ), ( y - HalfedDim.height ) / Math.pow( 1.004, tertiaryXslider ), videoSequenceLoopQuantity, 999, 1680, halfSreenDiagionalLength, false );//For Proper Rainbow PsychaHypnotic //Unknown Anomaly Like Shrunken Tangent Determining Disk Being Scanned By My Cybertron Steel 9600 Computer And Shows Atoms That Cannot Become More Resolute At The Present Time Or Ever!?
					/*cheapFractalAdjustedtertiaryXslider = tertiaryXslider * 480 / videoSequenceLoopQuantity;
				if ( cheapFractalAdjustedtertiaryXslider < 240 )//For Fractal
					tertiaryXsliderBackAndFourth = cheapFractalAdjustedtertiaryXslider;//For Fractal
				else//For Fractal
					tertiaryXsliderBackAndFourth = 480 - cheapFractalAdjustedtertiaryXslider;// */
					//System.out.println("x: " + x +" y: " + y + " cheapFractalAdjustedtertiaryXslider: " + cheapFractalAdjustedtertiaryXslider);
					//pattern2D.RainbowCheapFractalVaryated( thirdScreen.getBounds().getWidth(), 0, tertiaryXsliderBackAndFourth,  x, y - HalfedDim.height, thirdScreen.getBounds().getWidth(), thirdScreen.getBounds().getWidth(), false );//Good Vibrant Version
					//pattern2D.RainbowCheapFractalVaryated( thirdScreen.getBounds().getWidth(), 0, tertiaryXsliderBackAndFourth,  x, y - HalfedDim.height, thirdScreen.getBounds().getWidth() / 6, thirdScreen.getBounds().getWidth(), false );//Rainbow Segment Version
					//pattern2D.RainbowCheapFractalVaryated( thirdScreen.getBounds().getWidth() / 3, 0, tertiaryXsliderBackAndFourth,  x, y - HalfedDim.height, thirdScreen.getBounds().getWidth(), thirdScreen.getBounds().getWidth(), false );//Rainbow With Even Ends Of 1 Color
					//tertiaryPW.setColor( x, y, diagnostics.ToFXColor() );
					//System.out.println("x: " + x +" y: " + y);
					//rainbowSoft2D.MagiElite( videoSequenceLoopQuantity, tertiaryXslider, 0., videoSequenceLoopQuantity, (int)x, (int)y, videoSequenceLoopQuantity, 24.6, 1., halfSreenDiagionalLength, false, 1., 2147483647, 1., 1., false, basispr, backgroundbasispr, origionalpr, Dim, typeOfDisplay, initialColorContrastingChoice, colorTooSimilarReplacementColor, colorDifference, invertBasisFromBackground, nextStepColorTooSimilarEffect );
					//rainbowSoft2D.Buddhism( videoSequenceLoopQuantity, tertiaryXslider, 0., sliderInterval, videoSequenceLoopQuantity, (int)x, (int)y, videoSequenceLoopQuantity, lengthOfColorBar, 24.6, 1., 1.14, halfSreenDiagionalLength, false, 1., 2147483647, 1., 1., false, basispr, backgroundbasispr, origionalpr, Dim, typeOfDisplay, colorTooSimilarReplacementColor, colorDifference, invertBasisFromBackground, nextStepColorTooSimilarEffect );
					//tertiaryPW.setColor( x, y, diagnostics.ToFXColor() );
					//tertiaryPW.setColor( x, y, basispr.getColor( x, y ) );
					//tertiaryPW.setColor( x, y, pattern2D.ToFXColor() );
					//tertiaryPW.setColor( x, y, rainbowSoft2D.ToFXColor() );
					tertiaryPW.setColor( x, y, rainbowSoft2D.MagiElite( videoSequenceLoopQuantity, tertiaryXslider, tertiaryXslider, videoSequenceLoopQuantity, (int)x - 21, (int)y - 21, videoSequenceLoopQuantity, 24.6, 88.8, 1., halfSreenDiagionalLength, false, 1., 2147483647, 1., 1., false, basispr, backgroundbasispr, origionalpr, Dim, typeOfDisplay, initialColorContrastingChoice, colorTooSimilarReplacementColor, colorDifference, invertBasisFromBackground, reversalOfBackgroundEffectsMaster, nextStepColorTooSimilarEffect ) );
					//tertiaryPW.setColor( x, y, rainbowSoft2D.Buddhism( videoSequenceLoopQuantity, tertiaryXslider, tertiaryXslider, sliderInterval, videoSequenceLoopQuantity, (int)x - 21, (int)y - 21, videoSequenceLoopQuantity, lengthOfColorBar, 24.6, 1., 1.014, 1.00000000,  halfSreenDiagionalLength, false, 1., 2147483647, 1., 1., false, basispr, backgroundbasispr, origionalpr, Dim, typeOfDisplay, initialColorContrastingChoice, colorTooSimilarReplacementColor, colorDifference, invertBasisFromBackground, reversalOfBackgroundEffectsMaster, nextStepColorTooSimilarEffect ) );// Don't Change Object To It To Make This Work Because It Could Be ARGB Or RGB
					//tertiaryPW.setColor( x, y, rainbowSoft2D.RainbowVideoTest( videoSequenceLoopQuantity, tertiaryXslider, tertiaryXslider, videoSequenceLoopQuantity, (int)x - 21, (int)y - 21, videoSequenceLoopQuantity, 24.6, 1., halfSreenDiagionalLength, false, 1., 2147483647, 1., 1., false, basispr, backgroundbasispr, origionalpr, Dim, typeOfDisplay, initialColorContrastingChoice, colorTooSimilarReplacementColor, colorDifference, invertBasisFromBackground, reversalOfBackgroundEffectsMaster, nextStepColorTooSimilarEffect ) );
				}
			}
			tertiaryImageView.setImage(tertiaryWritableImage);

			thirdStackPane[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1] = new StackPane();
			System.out.println("(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1 = " + (int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1);
			//thirdStackPane[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1].getChildren().add(browser);
			//thirdStackPane[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1].getChildren().remove(0);
			thirdStackPane[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1].getChildren().add(tertiaryImageView);
			//End Of tertiaryXslider Loop For .3db Video Production .3da Should Be For Abstract 3-D Video Compression .3dc Should For Degraded 3-D Video Compression .3dm Should Be For Standard 3D Videos
			//.3dv Should Be For 3-D Virtual Environment Integration And Interoperability With 2-D Pictures And Video And Interactive Audio Management.
			thirdScene[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1] = new Scene(thirdStackPane[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1]);//Each A 3D Image
			thirdStackPane[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1].getScene().snapshot(tertiaryBufferPicture);
			//BAD tertiaryCurrentBrowserImage = thirdStackPane[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1].getScene().snapshot(tertiaryBufferPicture);// !!!!! Uncomment To Show Video !!!!!
			//tertiaryStage.setFullScreen(tertiaryIsFullScreened);
			//tertiaryStage.show();// !!!!! Uncomment To Show Video !!!!!

			tertiaryStage.setScene(thirdScene[(int)(videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity + 1 )]);

			System.out.println(Dim);

			//tertiaryStage.setFullScreen(tertiaryIsFullScreened);// ASDF !!!! HERE ! Important For Full Screened
			tertiaryStage.show(); // !!!!! Uncomment To Show Video !!!!!
			//tertiaryStage.setFullScreen(tertiaryIsFullScreened);// Important For Full Screened
			bImage = SwingFXUtils.fromFXImage(thirdScene[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1].snapshot( tertiaryWritableImage ), bImage );

			if ( tertiaryXslider < 1 && tertiaryXslider > -1 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
			{
				try {
					File outputFile = new File("C:/TestImage00.png");
					ImageIO.write(bImage, "png", outputFile);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			else
				if ( tertiaryXslider > 142 && tertiaryXslider <= 143 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
				{
					try {
						File outputFile = new File("C:/TestImage01.png");
						ImageIO.write(bImage, "png", outputFile);
					} catch (IOException e) {
						throw new RuntimeException(e);
					}
				}
				else
					if ( tertiaryXslider > 285 && tertiaryXslider <= 286 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
					{
						try {
							File outputFile = new File("C:/TestImage02.png");
							ImageIO.write(bImage, "png", outputFile);
						} catch (IOException e) {
							throw new RuntimeException(e);
						}
					}
					else
						if ( tertiaryXslider > 489 && tertiaryXslider <= 490 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
						{//428 && tertiaryXslider <= 429
							try {
								File outputFile = new File("C:/TestImage03.png");
								ImageIO.write(bImage, "png", outputFile);
							} catch (IOException e) {
								throw new RuntimeException(e);
							}
						}
						else
							if ( tertiaryXslider > 571 && tertiaryXslider <= 572 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
							{
								try {
									File outputFile = new File("C:/TestImage04.png");
									ImageIO.write(bImage, "png", outputFile);
								} catch (IOException e) {
									throw new RuntimeException(e);
								}
							}
							else
								if ( tertiaryXslider > 714 && tertiaryXslider <= 715 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
								{
									try {
										File outputFile = new File("C:/TestImage05.png");
										ImageIO.write(bImage, "png", outputFile);
									} catch (IOException e) {
										throw new RuntimeException(e);
									}
								}
								else
									if ( tertiaryXslider > 857 && tertiaryXslider <= 858 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
									{
										try {
											File outputFile = new File("C:/TestImage06.png");
											ImageIO.write(bImage, "png", outputFile);
										} catch (IOException e) {
											throw new RuntimeException(e);
										}
									}
									else
										if ( tertiaryXslider > 1000 && tertiaryXslider <= 1001 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
										{
											try {
												File outputFile = new File("C:/TestImage07.png");
												ImageIO.write(bImage, "png", outputFile);
											} catch (IOException e) {
												throw new RuntimeException(e);
											}
										}
										else
											if ( tertiaryXslider > 1143 && tertiaryXslider <= 1144 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
											{
												try {
													File outputFile = new File("C:/TestImage08.png");
													ImageIO.write(bImage, "png", outputFile);
												} catch (IOException e) {
													throw new RuntimeException(e);
												}
											}
											else
												if ( tertiaryXslider > 1286 && tertiaryXslider <= 1287 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
												{
													try {
														File outputFile = new File("C:/TestImage09.png");
														ImageIO.write(bImage, "png", outputFile);
													} catch (IOException e) {
														throw new RuntimeException(e);
													}
												}
												else
													if ( tertiaryXslider > 1429 && tertiaryXslider <= 1430 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
													{
														try {
															File outputFile = new File("C:/TestImage10.png");
															ImageIO.write(bImage, "png", outputFile);
														} catch (IOException e) {
															throw new RuntimeException(e);
														}
													}
													else
														if ( tertiaryXslider > 1572 && tertiaryXslider <= 1573 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
														{
															try {
																File outputFile = new File("C:/TestImage11.png");
																ImageIO.write(bImage, "png", outputFile);
															} catch (IOException e) {
																throw new RuntimeException(e);
															}
														}
														else
															if ( tertiaryXslider > 1714 && tertiaryXslider <= 1715 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
															{
																try {
																	File outputFile = new File("C:/TestImage12.png");
																	ImageIO.write(bImage, "png", outputFile);
																} catch (IOException e) {
																	throw new RuntimeException(e);
																}
															}
															else
																if ( tertiaryXslider > 1857 && tertiaryXslider <= 1858 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																{
																	try {
																		File outputFile = new File("C:/TestImage13.png");
																		ImageIO.write(bImage, "png", outputFile);
																	} catch (IOException e) {
																		throw new RuntimeException(e);
																	}
																}
																else
																	if ( tertiaryXslider > 2000 && tertiaryXslider <= 2001 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																	{
																		try {
																			File outputFile = new File("C:/TestImage14.png");
																			ImageIO.write(bImage, "png", outputFile);
																		} catch (IOException e) {
																			throw new RuntimeException(e);
																		}
																	}
																	else
																		if ( tertiaryXslider > 2143 && tertiaryXslider <= 2144 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																		{
																			try {
																				File outputFile = new File("C:/TestImage15.png");
																				ImageIO.write(bImage, "png", outputFile);
																			} catch (IOException e) {
																				throw new RuntimeException(e);
																			}
																		}
																		else
																			if ( tertiaryXslider > 2286 && tertiaryXslider <= 2287 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																			{
																				try {
																					File outputFile = new File("C:/TestImage16.png");
																					ImageIO.write(bImage, "png", outputFile);
																				} catch (IOException e) {
																					throw new RuntimeException(e);
																				}
																			}
																			else
																				if ( tertiaryXslider > 2429 && tertiaryXslider <= 2430 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																				{
																					try {
																						File outputFile = new File("C:/TestImage17.png");
																						ImageIO.write(bImage, "png", outputFile);
																					} catch (IOException e) {
																						throw new RuntimeException(e);
																					}
																				}
																				else
																					if ( tertiaryXslider > 2572 && tertiaryXslider <= 2573 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																					{
																						try {
																							File outputFile = new File("C:/TestImage18.png");
																							ImageIO.write(bImage, "png", outputFile);
																						} catch (IOException e) {
																							throw new RuntimeException(e);
																						}
																					}
																					else
																						if ( tertiaryXslider > 2715 && tertiaryXslider <= 2716 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																						{
																							try {
																								File outputFile = new File("C:/TestImage19.png");
																								ImageIO.write(bImage, "png", outputFile);
																							} catch (IOException e) {
																								throw new RuntimeException(e);
																							}
																						}
																						else
																							if ( tertiaryXslider > 2858 && tertiaryXslider <= 2859 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																							{
																								try {
																									File outputFile = new File("C:/TestImage20.png");
																									ImageIO.write(bImage, "png", outputFile);
																								} catch (IOException e) {
																									throw new RuntimeException(e);
																								}
																							}
																							else
																								if ( tertiaryXslider > 3001 && tertiaryXslider <= 3002 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																								{
																									try {
																										File outputFile = new File("C:/TestImage21.png");
																										ImageIO.write(bImage, "png", outputFile);
																									} catch (IOException e) {
																										throw new RuntimeException(e);
																									}
																								}
																								else
																									if ( tertiaryXslider > 3144 && tertiaryXslider <= 3145 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																									{
																										try {
																											File outputFile = new File("C:/TestImage22.png");
																											ImageIO.write(bImage, "png", outputFile);
																										} catch (IOException e) {
																											throw new RuntimeException(e);
																										}
																									}
																									else
																										if ( tertiaryXslider > 3287 && tertiaryXslider <= 3288 )//(int)Math.round(colorDisplacement) + radialDistance * 2 * Math.PI / numberOfClockHandsForRainbow / 2)
																										{
																											try {
																												File outputFile = new File("C:/TestImage23.png");
																												ImageIO.write(bImage, "png", outputFile);
																											} catch (IOException e) {
																												throw new RuntimeException(e);
																											}
																										}// */
			try {
				System.out.println( "bImage Height: " + bImage.getHeight() );
				encoder.encodeImage( bImage );
				//encoder.encodeImage( bImage.getSubimage( 0, 0, 666, 888 ) );
			}
			catch(IOException ie) { ie.printStackTrace(); }
			System.out.println("Finished Encoding Frame: " + (int)Math.round( ( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1 ) );

			if ( tertiaryXslider != 0 && tertiaryXslider / ( sliderInterval * numberOfScrollFrames ) - Math.floor( tertiaryXslider / ( sliderInterval * numberOfScrollFrames ) ) < .0001)//interval * 11->Twice + (int)(tertiaryXslider / ( interval * 11 )) + " );\r\n" + 
			{
				try ( PrintWriter printWriterOut = new PrintWriter(thirdXSliderFile.getPath() ) )
				{
					printWriterOut.println("+" + tertiaryXslider + "d");
					printWriterOut.close();
				}
				catch(IOException ie) { ie.printStackTrace(); }// */
				try ( PrintWriter printWriterOut = new PrintWriter(thirdJavaScriptFile.getPath() ) )
				{
					printWriterOut.println("function scrollContinuously( timeInterval )\r\n" + 
							"{\r\n" + 
							"	timeInterval = 444;\r\n" + 
							"	window.setInterval( scrollWin, timeInterval );\r\n" + 
							"}\r\n" + 
							"function scrollWin()\r\n" + 
							"{\r\n" + 
							"    window.scrollBy( 0, 100 )\\r\\n" +
							"}");
					printWriterOut.close();
				}
				catch(IOException ie) { ie.printStackTrace(); }// */
				//scrollHappened = true;
			}
			/*if (scrollHappened)
		{
			scrollHappened = false;
			//thirdBrowserEngine.executeScript(script);
			thirdBrowserEngine.load( "http://www.pixies.zone/PixiesTest%20-%20Copy%20(3).html" );
			thirdBrowserEngine.reload();
			return;
		}// */ //System.out.println(thirdJavaScriptFile.toString());
			//thirdBrowser.getEngine().load("file:///C:/Users/AllAV/Desktop/FWA%20Website/pixies.zone/PixiesTest%20-%20Copy%20(2).html");

			//fullScreened = tertiaryStage.isFullScreen();

			/*thirdScene[(int)( videoFrameQuantity * ( tertiaryXslider - startingPoint ) / videoSequenceLoopQuantity ) + 1].setOnKeyReleased(new EventHandler<KeyEvent>()
	{
		@Override
		public void handle(KeyEvent event)
		{
			if ( event.isAltDown() == true)
			{
				switch (event.getCode())
				{
				case ENTER: tertiaryStage.setFullScreen(!tertiaryStage.isFullScreen()); break;
				}
			}
		}
	});// */
			System.out.println("tertiaryXslider: " + tertiaryXslider);
			tertiaryXslider = tertiaryXslider + sliderInterval;
			//System.out.println(Dim);

			//}
			//Thread.sleep(2000);}
			//catch (Exception ex) {ex.printStackTrace();}
		}
		System.out.println("Main Program Loop Over");
		// Finalize the encoding, i.e. clear the buffers, write the header, etc.
		try {
			encoder.finish();
		}
		catch(IOException ie) { ie.printStackTrace(); }
		finally {
			NIOUtils.closeQuietly(tertiaryVideoOut);
		}
		System.exit(0);
		return bImage;
	}
}