Type TGradient

	Field colors:Int
	Field steps:Int
	Field inverse:Int

	Field P:Float[256 + 1]
	Field R:Int[256 + 1]
	Field G:Int[256 + 1]
	Field B:Int[256 + 1]
	
	Field GradientPercent:Float[256 + 1]
	Field GradientRed:Int[256 + 1]
	Field GradientGreen:Int[256 + 1]
	Field GradientBlue:Int[256 + 1]
	
	' --------------------------------------------------------------------------------------------
	' METHOD: Add new Gradient
	' --------------------------------------------------------------------------------------------
	Method Generate(class:String)

		Local i:Int, pos1:Int, pos2:Int, pdiff:Int
		Local rdiff:Int, gdiff:Int, bdiff:Int
		Local rstep:Float, gstep:Float, bstep:Float
		Local counter:Int = 0
		
		Local Percent:Float, Red:Int, Green:Int, Blue:Int
		
		Select class
		
			Case "O" RestoreData ClassO
			Case "B" RestoreData ClassB
			Case "A" RestoreData ClassA
			Case "F" RestoreData ClassF
			Case "G" RestoreData ClassG
			Case "K" RestoreData ClassK
			Case "M" RestoreData ClassM
			Case "D" RestoreData ClassD

			Case "OS" RestoreData Ostar
			Case "BS" RestoreData Bstar
			Case "AS" RestoreData Astar
			Case "FS" RestoreData Fstar
			Case "GS" RestoreData Gstar
			Case "KS" RestoreData Kstar
			Case "MS" RestoreData Mstar
			Case "DS" RestoreData Dstar
			
		End Select
		
		ReadData colors, steps, inverse

		If inverse Then
		
			For i = colors To 1 Step - 1
							
				ReadData Percent, Red, Green, Blue
			
				GradientPercent[i] = 100.0 - Percent
				GradientRed[i] = Red
				GradientGreen[i] = Green
				GradientBlue[i] = Blue

			Next
		
		Else
		
			For i = 1 To colors Step 1
			
				ReadData Percent, Red, Green, Blue
			
				GradientPercent[i] = Percent
				GradientRed[i] = Red
				GradientGreen[i] = Green
				GradientBlue[i] = Blue
			
			Next
		
		EndIf
		
		While counter < colors
		
			pos1 = GradientPercent[counter] * steps * 1.0 / 100
			pos2 = GradientPercent[counter + 1] * steps * 1.0 / 100
			
			If pos1 > Steps Then pos1 = Steps
			If pos2 > Steps Then pos2 = Steps
						
			pdiff = pos2 - pos1
			
			rdiff = GradientRed[counter] - GradientRed[counter + 1]
			gdiff = GradientGreen[counter] - GradientGreen[counter + 1]
			bdiff = GradientBlue[counter] - GradientBlue[counter + 1]
			
			rstep = rdiff * 1.0 / pdiff
			gstep = gdiff * 1.0 / pdiff
			bstep = bdiff * 1.0 / pdiff
			
			For i=0 To pdiff
					
				R[pos1 + i] = Int(GradientRed[counter] - (rstep * i))
				g[pos1 + i] = Int(GradientGreen[counter] - (gstep * i))
				B[pos1 + i] = Int(GradientBlue[counter] - (bstep * i))
				
			Next
			
			counter = counter + 1
			
		Wend
	
	End Method


End Type

# ClassM
DefData 4, 256, 0
DefData 0.0, 0, 0, 0
DefData 33.0, 255, 0, 0
DefData 66.0, 255, 0, 0
DefData 100.0, 255, 128, 0

# ClassK
DefData 4, 256, 0
DefData 0.0, 0, 0, 0
DefData 33.0, 192, 0, 0
DefData 66.0, 255, 128, 0
DefData 100.0, 255, 192, 0

# ClassG
DefData 4, 256, 0
DefData 0.0, 0, 0, 0
DefData 33.0, 255, 64, 0
DefData 66.0, 255, 128, 0
DefData 100.0, 255, 255, 192

# ClassF
DefData 4, 256, 0
DefData 0.0, 0, 0, 0
DefData 33.0, 255, 128, 128
DefData 66.0, 255, 255, 128
DefData 100.0, 255, 255, 192

# ClassA
DefData 4, 256, 0
DefData 0.0, 0, 0, 0
DefData 33.0, 224, 224, 255
DefData 66.0, 224, 240, 255
DefData 100.0, 255, 255, 255

# ClassB
DefData 4, 256, 0
DefData 0.0, 0, 0, 0
DefData 33.0, 192, 192, 255
DefData 66.0, 192, 224, 255
DefData 100.0, 255, 255, 255

# ClassO
DefData 4, 256, 0
DefData 0.0, 0, 0, 0
DefData 33.0, 128, 128, 255
DefData 66.0, 128, 192, 255
DefData 100.0, 255, 255, 255

# ClassD
DefData 4, 256, 0
DefData 0.0, 0, 0, 0
DefData 0.0, 0, 0, 0
DefData 80.0, 255, 255, 255
DefData 100.0, 255, 255, 255

# Mstar
DefData 3, 256, 0
DefData 0.0, 0, 0, 0
DefData 75.0, 191, 48, 0
DefData 100.0, 255, 255, 255

# Kstar
DefData 3, 256, 0
DefData 0.0, 0, 0, 0
DefData 75.0, 191, 96, 0
DefData 100.0, 255, 255, 255

# Gstar
DefData 3, 256, 0
DefData 0.0, 0, 0, 0
DefData 75.0, 191, 169, 0
DefData 100.0, 255, 255, 255

# Fstar
DefData 3, 256, 0
DefData 0.0, 0, 0, 0
DefData 75.0, 191, 191, 96
DefData 100.0, 255, 255, 255

# Astar
DefData 3, 256, 0
DefData 0.0, 0, 0, 0
DefData 75.0, 168, 180, 191
DefData 100.0, 255, 255, 255

# Bstar
DefData 3, 256, 0
DefData 0.0, 0, 0, 0
DefData 75.0, 143, 167, 191
DefData 100.0, 255, 255, 255

# Ostar
DefData 3, 256, 0
DefData 0.0, 0, 0, 0
DefData 75.0, 96, 143, 191
DefData 100.0, 255, 255, 255

# Dstar
DefData 4, 256, 0
DefData 0.0, 0, 0, 0
DefData 96.0, 229, 229, 225
DefData 98.0, 229, 242, 225
DefData 100.0, 255, 255, 255