
loadScript LoopToGo\libs\Novation\colorPaletteAliases.txt

function getPaletteColorfromRGB // noColor [out] r [in] g [in] b [in]

	variable alreadyComputedColor gAlreadyComputedColor & $arg2 & $arg3 & $arg4
	
	// Unfortunatly, we always compute black!!!
	if $$alreadyComputedColor > 0 
		parentVariable $arg1 $$alreadyComputedColor
		//print Use $alreadyComputedColor : $$alreadyComputedColor
		exitFunction
	endIf
	
	callFunction findClosestColorFromPalette noColor $arg2  $arg3  $arg4
	
	globalVariable $alreadyComputedColor $noColor
	
	//print Computed new color $alreadyComputedColor : $$alreadyComputedColor

	parentVariable $arg1 $noColor

endFunction

function computeDistanceRGB // dist [out] r1 [in] g1 [in] b1 [in] r2 [in] g2 [in] b2 [in] 
	
	variable dr $arg2 - $arg5
	variable dg $arg3 - $arg6
	variable db $arg4 - $arg7
		
	parentVariable $arg1 $dr*$dr + $dg*$dg + $db*$db 
	
endFunction


// 
function findClosestColorFromPalette // noColor [out] r [in] g [in] b [in]

	variable lowestDistanceRGB 100000000000000000
	variable closestColor 0
	
	variable red $arg2
	variable green $arg3
	variable blue $arg4


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed0 aLPMGreen0 aLPMBlue0

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 0
	endIf


	// Note, we intentionally don't use a for loop here because we want to be fast and also use alias instead of variable to not polute the variables space!
	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed1 aLPMGreen1 aLPMBlue1
	
	
	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 1
	endIf
	
	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed2 aLPMGreen2 aLPMBlue2

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 2
	endIf

	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed3 aLPMGreen3 aLPMBlue3

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 3
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed4 aLPMGreen4 aLPMBlue4

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 4
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed5 aLPMGreen5 aLPMBlue5

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 5
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed6 aLPMGreen6 aLPMBlue6

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 6
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed7 aLPMGreen7 aLPMBlue7

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 7
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed8 aLPMGreen8 aLPMBlue8

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 8
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed9 aLPMGreen9 aLPMBlue9

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 9
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed10 aLPMGreen10 aLPMBlue10

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 10
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed11 aLPMGreen11 aLPMBlue11

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 11
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed12 aLPMGreen12 aLPMBlue12

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 12
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed13 aLPMGreen13 aLPMBlue13

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 13
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed14 aLPMGreen14 aLPMBlue14

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 14
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed15 aLPMGreen15 aLPMBlue15

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 15
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed16 aLPMGreen16 aLPMBlue16

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 16
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed17 aLPMGreen17 aLPMBlue17

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 17
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed18 aLPMGreen18 aLPMBlue18

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 18
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed19 aLPMGreen19 aLPMBlue19

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 19
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed20 aLPMGreen20 aLPMBlue20

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 20
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed21 aLPMGreen21 aLPMBlue21

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 21
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed22 aLPMGreen22 aLPMBlue22

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 22
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed23 aLPMGreen23 aLPMBlue23

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 23
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed24 aLPMGreen24 aLPMBlue24

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 24
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed25 aLPMGreen25 aLPMBlue25

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 25
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed26 aLPMGreen26 aLPMBlue26

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 26
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed27 aLPMGreen27 aLPMBlue27

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 27
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed28 aLPMGreen28 aLPMBlue28

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 28
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed29 aLPMGreen29 aLPMBlue29

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 29
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed30 aLPMGreen30 aLPMBlue30

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 30
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed31 aLPMGreen31 aLPMBlue31

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 31
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed32 aLPMGreen32 aLPMBlue32

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 32
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed33 aLPMGreen33 aLPMBlue33

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 33
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed34 aLPMGreen34 aLPMBlue34

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 34
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed35 aLPMGreen35 aLPMBlue35

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 35
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed36 aLPMGreen36 aLPMBlue36

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 36
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed37 aLPMGreen37 aLPMBlue37

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 37
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed38 aLPMGreen38 aLPMBlue38

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 38
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed39 aLPMGreen39 aLPMBlue39

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 39
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed40 aLPMGreen40 aLPMBlue40

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 40
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed41 aLPMGreen41 aLPMBlue41

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 41
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed42 aLPMGreen42 aLPMBlue42

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 42
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed43 aLPMGreen43 aLPMBlue43

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 43
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed44 aLPMGreen44 aLPMBlue44

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 44
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed45 aLPMGreen45 aLPMBlue45

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 45
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed46 aLPMGreen46 aLPMBlue46

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 46
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed47 aLPMGreen47 aLPMBlue47

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 47
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed48 aLPMGreen48 aLPMBlue48

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 48
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed49 aLPMGreen49 aLPMBlue49

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 49
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed50 aLPMGreen50 aLPMBlue50

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 50
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed51 aLPMGreen51 aLPMBlue51

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 51
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed52 aLPMGreen52 aLPMBlue52

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 52
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed53 aLPMGreen53 aLPMBlue53

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 53
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed54 aLPMGreen54 aLPMBlue54

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 54
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed55 aLPMGreen55 aLPMBlue55

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 55
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed56 aLPMGreen56 aLPMBlue56

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 56
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed57 aLPMGreen57 aLPMBlue57

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 57
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed58 aLPMGreen58 aLPMBlue58

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 58
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed59 aLPMGreen59 aLPMBlue59

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 59
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed60 aLPMGreen60 aLPMBlue60

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 60
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed61 aLPMGreen61 aLPMBlue61

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 61
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed62 aLPMGreen62 aLPMBlue62

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 62
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed63 aLPMGreen63 aLPMBlue63

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 63
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed64 aLPMGreen64 aLPMBlue64

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 64
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed65 aLPMGreen65 aLPMBlue65

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 65
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed66 aLPMGreen66 aLPMBlue66

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 66
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed67 aLPMGreen67 aLPMBlue67

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 67
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed68 aLPMGreen68 aLPMBlue68

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 68
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed69 aLPMGreen69 aLPMBlue69

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 69
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed70 aLPMGreen70 aLPMBlue70

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 70
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed71 aLPMGreen71 aLPMBlue71

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 71
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed72 aLPMGreen72 aLPMBlue72

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 72
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed73 aLPMGreen73 aLPMBlue73

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 73
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed74 aLPMGreen74 aLPMBlue74

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 74
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed75 aLPMGreen75 aLPMBlue75

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 75
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed76 aLPMGreen76 aLPMBlue76

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 76
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed77 aLPMGreen77 aLPMBlue77

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 77
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed78 aLPMGreen78 aLPMBlue78

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 78
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed79 aLPMGreen79 aLPMBlue79

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 79
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed80 aLPMGreen80 aLPMBlue80

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 80
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed81 aLPMGreen81 aLPMBlue81

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 81
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed82 aLPMGreen82 aLPMBlue82

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 82
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed83 aLPMGreen83 aLPMBlue83

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 83
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed84 aLPMGreen84 aLPMBlue84

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 84
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed85 aLPMGreen85 aLPMBlue85

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 85
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed86 aLPMGreen86 aLPMBlue86

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 86
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed87 aLPMGreen87 aLPMBlue87

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 87
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed88 aLPMGreen88 aLPMBlue88

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 88
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed89 aLPMGreen89 aLPMBlue89

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 89
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed90 aLPMGreen90 aLPMBlue90

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 90
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed91 aLPMGreen91 aLPMBlue91

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 91
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed92 aLPMGreen92 aLPMBlue92

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 92
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed93 aLPMGreen93 aLPMBlue93

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 93
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed94 aLPMGreen94 aLPMBlue94

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 94
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed95 aLPMGreen95 aLPMBlue95

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 95
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed96 aLPMGreen96 aLPMBlue96

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 96
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed97 aLPMGreen97 aLPMBlue97

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 97
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed98 aLPMGreen98 aLPMBlue98

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 98
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed99 aLPMGreen99 aLPMBlue99

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 99
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed100 aLPMGreen100 aLPMBlue100

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 100
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed101 aLPMGreen101 aLPMBlue101

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 101
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed102 aLPMGreen102 aLPMBlue102

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 102
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed103 aLPMGreen103 aLPMBlue103

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 103
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed104 aLPMGreen104 aLPMBlue104

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 104
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed105 aLPMGreen105 aLPMBlue105

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 105
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed106 aLPMGreen106 aLPMBlue106

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 106
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed107 aLPMGreen107 aLPMBlue107

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 107
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed108 aLPMGreen108 aLPMBlue108

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 108
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed109 aLPMGreen109 aLPMBlue109

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 109
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed110 aLPMGreen110 aLPMBlue110

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 110
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed111 aLPMGreen111 aLPMBlue111

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 111
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed112 aLPMGreen112 aLPMBlue112

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 112
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed113 aLPMGreen113 aLPMBlue113

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 113
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed114 aLPMGreen114 aLPMBlue114

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 114
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed115 aLPMGreen115 aLPMBlue115

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 115
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed116 aLPMGreen116 aLPMBlue116

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 116
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed117 aLPMGreen117 aLPMBlue117

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 117
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed118 aLPMGreen118 aLPMBlue118

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 118
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed119 aLPMGreen119 aLPMBlue119

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 119
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed120 aLPMGreen120 aLPMBlue120

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 120
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed121 aLPMGreen121 aLPMBlue121

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 121
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed122 aLPMGreen122 aLPMBlue122

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 122
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed123 aLPMGreen123 aLPMBlue123

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 123
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed124 aLPMGreen124 aLPMBlue124

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 124
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed125 aLPMGreen125 aLPMBlue125

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 125
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed126 aLPMGreen126 aLPMBlue126

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 126
	endIf


	callFunction computeDistanceRGB distanceRGB $red $green $blue aLPMRed127 aLPMGreen127 aLPMBlue127

	if $distanceRGB < $lowestDistanceRGB
		variable lowestDistanceRGB $distanceRGB
		variable closestColor 127
	endIf
	
	parentVariable $arg1 $closestColor
	
	
endFunction	



