Get a Distinctive Color from a Set of Colors
hrodstein
// GetIndexedRGBColor(colorIndex, red, green, blue)
// Given an index from 0 to 15, returns a color as r, g and b.
// colorIndex is an input. red, green and blue are outputs.
// Example:
// Function Test()
// Variable i
// for(i=0; i<10; i+=1)
// Variable red, green, blue
// GetColor(i, red, green, blue)
// Printf "%d: red=%d, green=%d, blue=%d\r", red, green, blue
// endfor
// End
Function GetIndexedRGBColor(colorIndex, red, green, blue)
Variable colorIndex
Variable &red, &green, &blue // Outputs
Variable numColors = 16 // Number of colors in the following switch
colorIndex = mod(colorIndex, numColors) // Wrap around if necessary
switch(colorIndex)
case 0: // Time wave
red = 0; green = 0; blue = 0; // Black
break
case 1:
red = 65535; green = 16385; blue = 16385; // Red
break
case 2:
red = 2; green = 39321; blue = 1; // Green
break
case 3:
red = 0; green = 0; blue = 65535; // Blue
break
case 4:
red = 39321; green = 1; blue = 31457; // Purple
break
case 5:
red = 39321; green = 39321; blue = 39321; // Gray
break
case 6:
red = 65535; green = 32768; blue = 32768; // Salmon
break
case 7:
red = 0; green = 65535; blue = 0; // Lime
break
case 8:
red = 16385; green = 65535; blue = 65535; // Turquoise
break
case 9:
red = 65535; green = 32768; blue = 58981; // Light purple
break
case 10:
red = 39321; green = 26208; blue = 1; // Brown
break
case 11:
red = 52428; green = 34958; blue = 1; // Light brown
break
case 12:
red = 65535; green = 32764; blue = 16385; // Orange
break
case 13:
red = 1; green = 52428; blue = 26586; // Teal
break
case 14:
red = 1; green = 3; blue = 39321; // Dark blue
break
case 15:
red = 65535; green = 49151; blue = 55704; // Pink
break
endswitch
End
// Given an index from 0 to 15, returns a color as r, g and b.
// colorIndex is an input. red, green and blue are outputs.
// Example:
// Function Test()
// Variable i
// for(i=0; i<10; i+=1)
// Variable red, green, blue
// GetColor(i, red, green, blue)
// Printf "%d: red=%d, green=%d, blue=%d\r", red, green, blue
// endfor
// End
Function GetIndexedRGBColor(colorIndex, red, green, blue)
Variable colorIndex
Variable &red, &green, &blue // Outputs
Variable numColors = 16 // Number of colors in the following switch
colorIndex = mod(colorIndex, numColors) // Wrap around if necessary
switch(colorIndex)
case 0: // Time wave
red = 0; green = 0; blue = 0; // Black
break
case 1:
red = 65535; green = 16385; blue = 16385; // Red
break
case 2:
red = 2; green = 39321; blue = 1; // Green
break
case 3:
red = 0; green = 0; blue = 65535; // Blue
break
case 4:
red = 39321; green = 1; blue = 31457; // Purple
break
case 5:
red = 39321; green = 39321; blue = 39321; // Gray
break
case 6:
red = 65535; green = 32768; blue = 32768; // Salmon
break
case 7:
red = 0; green = 65535; blue = 0; // Lime
break
case 8:
red = 16385; green = 65535; blue = 65535; // Turquoise
break
case 9:
red = 65535; green = 32768; blue = 58981; // Light purple
break
case 10:
red = 39321; green = 26208; blue = 1; // Brown
break
case 11:
red = 52428; green = 34958; blue = 1; // Light brown
break
case 12:
red = 65535; green = 32764; blue = 16385; // Orange
break
case 13:
red = 1; green = 52428; blue = 26586; // Teal
break
case 14:
red = 1; green = 3; blue = 39321; // Dark blue
break
case 15:
red = 65535; green = 49151; blue = 55704; // Pink
break
endswitch
End
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More