src/codeandchords/ModuleMenu.java
public void trichromatic_ThreeRGB(int[] rgbVals1, int[] rgbVals2, int[] rgbVals3, int inputNum)
	{
		if(rgbVals1 == null || rgbVals2 == null || rgbVals3 == null) {
			throw new IllegalArgumentException("Module_01_02.trichromatic_ThreeRGB: at least one of the float[] parameters is null.");
		} // error checking

		int	color1pos	= 0;
		int	color2pos;
		int	color3pos;

		int	divideBy1;
		int	divideBy2;
		int	divideBy3;

		if(this.majMinChrom == 2)
		{
			// if chromatic scale, put the colors equally throughout:
			color2pos	= this.scaleLength / 3;
			color3pos	= (this.scaleLength / 3) * 2;

			divideBy1	= Math.max((color2pos - color1pos), 1);
			divideBy2	= Math.max((color3pos - color2pos), 1);
			divideBy3	= Math.max((this.scaleLength - color3pos), 1);
		} else {
			// These are their positions in trichromColors:
			color2pos	= 3;	// subdominant
			color3pos	= 4;	// dominant

			// (5 and 7 are the positions in colorSelect):
			//			color2pos	= 5;	// subdominant
			//			color3pos	= 7;	// dominant

			divideBy1	= 3;
			divideBy2	= 1;
			divideBy3	= 3;
		}

		int	redDelta1	= (int)((rgbVals1[0] - rgbVals2[0]) / divideBy1);
		int	greenDelta1	= (int)((rgbVals1[1] - rgbVals2[1]) / divideBy1);
		int	blueDelta1	= (int)((rgbVals1[2] - rgbVals2[2]) / divideBy1);

		int	redDelta2	= (int)((rgbVals2[0] - rgbVals3[0]) / divideBy2);
		int	greenDelta2	= (int)((rgbVals2[1] - rgbVals3[1]) / divideBy2);
		int	blueDelta2	= (int)((rgbVals2[2] - rgbVals3[2]) / divideBy2);

		int	redDelta3	= (int)((rgbVals3[0] - rgbVals1[0]) / divideBy3);
		int	greenDelta3	= (int)((rgbVals3[1] - rgbVals1[1]) / divideBy3);
		int	blueDelta3	= (int)((rgbVals3[2] - rgbVals1[2]) / divideBy3);

		/*		
		System.out.println("redDelta1 = " + redDelta1 + "; greenDelta1 = " + greenDelta1 + "; blueDelta1 = " + blueDelta1);
		System.out.println("redDelta2 = " + redDelta2 + "; greenDelta2 = " + greenDelta1 + "; blueDelta2 = " + blueDelta2);
		System.out.println("redDelta3 = " + redDelta3 + "; greenDelta3 = " + greenDelta1 + "; blueDelta3 = " + blueDelta3);
		 */
		// This array has the trichromatic spectrum:
		int[][]	trichromColors	= new int[this.scaleLength][3];

		// fill first position with first color:
		for(int i = 0; i < rgbVals1.length; i++)
		{
			trichromColors[0][i]	= rgbVals1[i];
		}

		// fill from first color to second color:
		for(int i = 1; i < color2pos; i++)
		{
			//			for(int j = 0; j < trichromColors[i].length; j++)
			//			{
			trichromColors[i][0]	= trichromColors[i - 1][0] - redDelta1;
			trichromColors[i][1]	= trichromColors[i - 1][1] - greenDelta1;
			trichromColors[i][2]	= trichromColors[i - 1][2] - blueDelta1;
			//			} // for - j
		} // for - first color to second color

		// Fill second color (in case the math is a little off, since we are rounding to ints, and it doesn't quite make it back):
		trichromColors[color2pos][0]	= rgbVals2[0];
		trichromColors[color2pos][1]	= rgbVals2[1];
		trichromColors[color2pos][2]	= rgbVals2[2];

		// fill from second color to third color:
		for(int i = color2pos + 1; i < color3pos; i++)
		{
			//			for(int j = 0; j < trichromColors[i].length; j++)
			//			{
			trichromColors[i][0]	= trichromColors[i - 1][0] - redDelta2;
			trichromColors[i][1]	= trichromColors[i - 1][1] - greenDelta2;
			trichromColors[i][2]	= trichromColors[i - 1][2] - blueDelta2;
			//			} // for - j
		} // for - first color to second color

		// Fill third color (in case the math is a little off, since we are rounding to ints, and it doesn't quite make it back):
		trichromColors[color3pos][0]	= rgbVals3[0];
		trichromColors[color3pos][1]	= rgbVals3[1];
		trichromColors[color3pos][2]	= rgbVals3[2];

		// fill from third color back to first color:
		for(int i = color3pos + 1; i < this.scaleLength; i++)
		{
			//			for(int j = 0; j < trichromColors[i].length; j++)
			//			{
			trichromColors[i][0]	= trichromColors[i - 1][0] - redDelta3;
			trichromColors[i][1]	= trichromColors[i - 1][1] - greenDelta3;
			trichromColors[i][2]	= trichromColors[i - 1][2] - blueDelta3;
			//			} // for - j
		} // for - third color to first color

		// fill colors with the trichrom spectrum; some colors will be repeated, as designated in scaleDegreeColors:
		int	trichromColorPos	= 0;

//		for(int i = this.startHere; i < this.endBeforeThis; i++)
//		{
			for(int j = 0; j < this.colors[inputNum].length && trichromColorPos < trichromColors.length; j++)
			{
				trichromColorPos	= this.getScaleDegreeColors()[this.majMinChrom][j];

				this.colors[inputNum][j]	= trichromColors[trichromColorPos];
			} // for - j
//		} // for - i

		this.fillHSBColors();
	}
/**
	 * Calculates the colors between the 3 sets of given vals
	 * and fills colors with a spectrum fading between them.
	 * 
	 * @param rgbVals1	rgb vals for the tonic color
	 * @param rgbVals2	rgb vals for the sub-dominant for major/minor scales or "5th scale degree" (counting by half steps) for chromatic scales
	 * @param rgbVals3	rgb vals for the dominant for major/minor scales or the "9th scale degree" (counting by half steps) for chromatic scales
	 */
Calculates the colors between the 3 sets of given vals
and fills colors with a spectrum fading between them.

@param rgbVals1      rgb vals for the tonic color
@param rgbVals2      rgb vals for the sub-dominant for major/minor scales or "5th scale degree" (counting by half steps) for chromatic scales
@param rgbVals3      rgb vals for the dominant for major/minor scales or the "9th scale degree" (counting by half steps) for chromatic scales
Calculates the colors between the 3 sets of given vals and fills colors with a spectrum fading between them . @param rgbVals1 rgb vals for the tonic color @param rgbVals2 rgb vals for the sub - dominant for major / minor scales or " 5th scale degree " ( counting by half steps ) for chromatic scales @param rgbVals3 rgb vals for the dominant for major / minor scales or the " 9th scale degree " ( counting by half steps ) for chromatic scales
public void trichromatic_ThreeRGB(int[] rgbVals1, int[] rgbVals2, int[] rgbVals3, int inputNum)
	{
		if(rgbVals1 == null || rgbVals2 == null || rgbVals3 == null) {
			throw new IllegalArgumentException("Module_01_02.trichromatic_ThreeRGB: at least one of the float[] parameters is null.");
		} 
		int	color1pos	= 0;
		int	color2pos;
		int	color3pos;
		int	divideBy1;
		int	divideBy2;
		int	divideBy3;
		if(this.majMinChrom == 2)
		{
			color2pos	= this.scaleLength / 3;
			color3pos	= (this.scaleLength / 3) * 2;
			divideBy1	= Math.max((color2pos - color1pos), 1);
			divideBy2	= Math.max((color3pos - color2pos), 1);
			divideBy3	= Math.max((this.scaleLength - color3pos), 1);
		} else {
			color2pos	= 3;	
			color3pos	= 4;	
			//			color2pos	= 5;	
			//			color3pos	= 7;	
			divideBy1	= 3;
			divideBy2	= 1;
			divideBy3	= 3;
		}
		int	redDelta1	= (int)((rgbVals1[0] - rgbVals2[0]) / divideBy1);
		int	greenDelta1	= (int)((rgbVals1[1] - rgbVals2[1]) / divideBy1);
		int	blueDelta1	= (int)((rgbVals1[2] - rgbVals2[2]) / divideBy1);
		int	redDelta2	= (int)((rgbVals2[0] - rgbVals3[0]) / divideBy2);
		int	greenDelta2	= (int)((rgbVals2[1] - rgbVals3[1]) / divideBy2);
		int	blueDelta2	= (int)((rgbVals2[2] - rgbVals3[2]) / divideBy2);
		int	redDelta3	= (int)((rgbVals3[0] - rgbVals1[0]) / divideBy3);
		int	greenDelta3	= (int)((rgbVals3[1] - rgbVals1[1]) / divideBy3);
		int	blueDelta3	= (int)((rgbVals3[2] - rgbVals1[2]) / divideBy3);
		/*		
		System.out.println("redDelta1 = " + redDelta1 + "; greenDelta1 = " + greenDelta1 + "; blueDelta1 = " + blueDelta1);
		System.out.println("redDelta2 = " + redDelta2 + "; greenDelta2 = " + greenDelta1 + "; blueDelta2 = " + blueDelta2);
		System.out.println("redDelta3 = " + redDelta3 + "; greenDelta3 = " + greenDelta1 + "; blueDelta3 = " + blueDelta3);
		 */
		int[][]	trichromColors	= new int[this.scaleLength][3];
		for(int i = 0; i < rgbVals1.length; i++)
		{
			trichromColors[0][i]	= rgbVals1[i];
		}
		for(int i = 1; i < color2pos; i++)
		{
			trichromColors[i][0]	= trichromColors[i - 1][0] - redDelta1;
			trichromColors[i][1]	= trichromColors[i - 1][1] - greenDelta1;
			trichromColors[i][2]	= trichromColors[i - 1][2] - blueDelta1;
		} 
		trichromColors[color2pos][0]	= rgbVals2[0];
		trichromColors[color2pos][1]	= rgbVals2[1];
		trichromColors[color2pos][2]	= rgbVals2[2];
		for(int i = color2pos + 1; i < color3pos; i++)
		{
			trichromColors[i][0]	= trichromColors[i - 1][0] - redDelta2;
			trichromColors[i][1]	= trichromColors[i - 1][1] - greenDelta2;
			trichromColors[i][2]	= trichromColors[i - 1][2] - blueDelta2;
		} 
		trichromColors[color3pos][0]	= rgbVals3[0];
		trichromColors[color3pos][1]	= rgbVals3[1];
		trichromColors[color3pos][2]	= rgbVals3[2];
		for(int i = color3pos + 1; i < this.scaleLength; i++)
		{
			trichromColors[i][0]	= trichromColors[i - 1][0] - redDelta3;
			trichromColors[i][1]	= trichromColors[i - 1][1] - greenDelta3;
			trichromColors[i][2]	= trichromColors[i - 1][2] - blueDelta3;
		} 
		int	trichromColorPos	= 0;
			for(int j = 0; j < this.colors[inputNum].length && trichromColorPos < trichromColors.length; j++)
			{
				trichromColorPos	= this.getScaleDegreeColors()[this.majMinChrom][j];
				this.colors[inputNum][j]	= trichromColors[trichromColorPos];
			} 
		this.fillHSBColors();
	}
public void trichromatic_ThreeRGB ( int [ ] rgbVals1 , int [ ] rgbVals2 , int [ ] rgbVals3 , int inputNum ) { if ( rgbVals1 == null || rgbVals2 == null || rgbVals3 == null ) { throw new IllegalArgumentException ( "Module_01_02.trichromatic_ThreeRGB: at least one of the float[] parameters is null." ) ; } int color1pos = 0 ; int color2pos ; int color3pos ; int divideBy1 ; int divideBy2 ; int divideBy3 ; if ( this . majMinChrom == 2 ) { color2pos = this . scaleLength / 3 ; color3pos = ( this . scaleLength / 3 ) * 2 ; divideBy1 = Math . max ( ( color2pos - color1pos ) , 1 ) ; divideBy2 = Math . max ( ( color3pos - color2pos ) , 1 ) ; divideBy3 = Math . max ( ( this . scaleLength - color3pos ) , 1 ) ; } else { color2pos = 3 ; color3pos = 4 ; divideBy1 = 3 ; divideBy2 = 1 ; divideBy3 = 3 ; } int redDelta1 = ( int ) ( ( rgbVals1 [ 0 ] - rgbVals2 [ 0 ] ) / divideBy1 ) ; int greenDelta1 = ( int ) ( ( rgbVals1 [ 1 ] - rgbVals2 [ 1 ] ) / divideBy1 ) ; int blueDelta1 = ( int ) ( ( rgbVals1 [ 2 ] - rgbVals2 [ 2 ] ) / divideBy1 ) ; int redDelta2 = ( int ) ( ( rgbVals2 [ 0 ] - rgbVals3 [ 0 ] ) / divideBy2 ) ; int greenDelta2 = ( int ) ( ( rgbVals2 [ 1 ] - rgbVals3 [ 1 ] ) / divideBy2 ) ; int blueDelta2 = ( int ) ( ( rgbVals2 [ 2 ] - rgbVals3 [ 2 ] ) / divideBy2 ) ; int redDelta3 = ( int ) ( ( rgbVals3 [ 0 ] - rgbVals1 [ 0 ] ) / divideBy3 ) ; int greenDelta3 = ( int ) ( ( rgbVals3 [ 1 ] - rgbVals1 [ 1 ] ) / divideBy3 ) ; int blueDelta3 = ( int ) ( ( rgbVals3 [ 2 ] - rgbVals1 [ 2 ] ) / divideBy3 ) ; /*		
		System.out.println("redDelta1 = " + redDelta1 + "; greenDelta1 = " + greenDelta1 + "; blueDelta1 = " + blueDelta1);
		System.out.println("redDelta2 = " + redDelta2 + "; greenDelta2 = " + greenDelta1 + "; blueDelta2 = " + blueDelta2);
		System.out.println("redDelta3 = " + redDelta3 + "; greenDelta3 = " + greenDelta1 + "; blueDelta3 = " + blueDelta3);
		 */ int [ ] [ ] trichromColors = new int [ this . scaleLength ] [ 3 ] ; for ( int i = 0 ; i < rgbVals1 . length ; i ++ ) { trichromColors [ 0 ] [ i ] = rgbVals1 [ i ] ; } for ( int i = 1 ; i < color2pos ; i ++ ) { trichromColors [ i ] [ 0 ] = trichromColors [ i - 1 ] [ 0 ] - redDelta1 ; trichromColors [ i ] [ 1 ] = trichromColors [ i - 1 ] [ 1 ] - greenDelta1 ; trichromColors [ i ] [ 2 ] = trichromColors [ i - 1 ] [ 2 ] - blueDelta1 ; } trichromColors [ color2pos ] [ 0 ] = rgbVals2 [ 0 ] ; trichromColors [ color2pos ] [ 1 ] = rgbVals2 [ 1 ] ; trichromColors [ color2pos ] [ 2 ] = rgbVals2 [ 2 ] ; for ( int i = color2pos + 1 ; i < color3pos ; i ++ ) { trichromColors [ i ] [ 0 ] = trichromColors [ i - 1 ] [ 0 ] - redDelta2 ; trichromColors [ i ] [ 1 ] = trichromColors [ i - 1 ] [ 1 ] - greenDelta2 ; trichromColors [ i ] [ 2 ] = trichromColors [ i - 1 ] [ 2 ] - blueDelta2 ; } trichromColors [ color3pos ] [ 0 ] = rgbVals3 [ 0 ] ; trichromColors [ color3pos ] [ 1 ] = rgbVals3 [ 1 ] ; trichromColors [ color3pos ] [ 2 ] = rgbVals3 [ 2 ] ; for ( int i = color3pos + 1 ; i < this . scaleLength ; i ++ ) { trichromColors [ i ] [ 0 ] = trichromColors [ i - 1 ] [ 0 ] - redDelta3 ; trichromColors [ i ] [ 1 ] = trichromColors [ i - 1 ] [ 1 ] - greenDelta3 ; trichromColors [ i ] [ 2 ] = trichromColors [ i - 1 ] [ 2 ] - blueDelta3 ; } int trichromColorPos = 0 ; for ( int j = 0 ; j < this . colors [ inputNum ] . length && trichromColorPos < trichromColors . length ; j ++ ) { trichromColorPos = this . getScaleDegreeColors ( ) [ this . majMinChrom ] [ j ] ; this . colors [ inputNum ] [ j ] = trichromColors [ trichromColorPos ] ; } this . fillHSBColors ( ) ; }
Calculates the colors between the 3 sets of given vals
 and fills colors with a spectrum fading between them.
Calculates the colors between the 3 sets of given vals and fills colors with a spectrum fading between them .
// error checking // if chromatic scale, put the colors equally throughout: // These are their positions in trichromColors: // subdominant // dominant // (5 and 7 are the positions in colorSelect): //			color2pos	= 5;	// subdominant //			color3pos	= 7;	// dominant // This array has the trichromatic spectrum: // fill first position with first color: // fill from first color to second color: //			for(int j = 0; j < trichromColors[i].length; j++) //			{ //			} // for - j // for - first color to second color // Fill second color (in case the math is a little off, since we are rounding to ints, and it doesn't quite make it back): // fill from second color to third color: //			for(int j = 0; j < trichromColors[i].length; j++) //			{ //			} // for - j // for - first color to second color // Fill third color (in case the math is a little off, since we are rounding to ints, and it doesn't quite make it back): // fill from third color back to first color: //			for(int j = 0; j < trichromColors[i].length; j++) //			{ //			} // for - j // for - third color to first color // fill colors with the trichrom spectrum; some colors will be repeated, as designated in scaleDegreeColors: //		for(int i = this.startHere; i < this.endBeforeThis; i++) //		{ // for - j //		} // for - i