Skip to content
Shane Saxon edited this page Nov 20, 2019 · 9 revisions

Color is defined in two ways, by palette_id with color_id and by RGBA values (all of these are defined in the node table).

  • Press '-' or '+' key to change color_id.
  • Press ALT+'-' or ALT+'+' to change palette_id.

*Note that alpha channel Transparency is set separately from the color and the RGB(A) value is not changed when switching color and palette ID's.

Users can set custom colors (in the GUI, or table), but when they do, the RGBA color will not correspond properly with the palette and color ID's. Also note that in the GUI if you change either palette or color_id, it will automatically set the RGBA color and the custom color will be lost.

Another exception is with 3D models, changing geometry to a custom 3D model will automatically change the RGBA values to 100% white (for texture mapping to appear in it's natural color), but the color & palette ID's will be left unchanged, when switching back to the set of hard-coded (geo) primitives, the color will revert back to its original ID values.


25 Color Palettes

Their are several hard-coded palettes:

  • palette_id = 0 is a distinct set of 20 colors.
  • palette_id 1-25 are gradients with 256 color_id's each.
  • Odd palette_id's are inverted colors (mirrors) of their Even numbered predecesor.
  • Most palette's are linear gradients between two colors (ie: blue to green).
  • 'Rainbow Heatmap' is a composite of several gradients (ie: purple to blue-green).
  • We plan to add more hard-coded and custom palettes in the future (ie: NWS heatmaps).

The palettes are generally a gradient (with 128 color_id's) between two colors, however some are more complex, such as the 'rainbow' palette.


Code that sets the RGBA color

  • npSetIndexColor() in 'npcolor.c' sets the nodes RGBA color based on palette_id and color_id.

switch( paletteID ) { case 0 : // use indexed color array above case 1 : // odd cases are inverted after switch statement

  	color->r = colorPalette[colorID][0];
  	color->g = colorPalette[colorID][1];
  	color->b = colorPalette[colorID][2];
  	break;
  case 2 :		///< rainbow heatmap
  case 3 :		///< rainbow heatmap inverted
  		if( colorID < 16 )			// light-pink to purple
  		{
  			color->r = 255 - colorID * 8;
  			color->g = 127 - colorID * 8;
  			color->b = 255 - colorID * 8;
  		}
  		else if( colorID < 32 )		// purple to blue-green
  		{
  			color->r = 255 - colorID * 8;
  			color->g = (colorID - 16) * 8;
  			color->b = (colorID - 16) * 8 + 127;
  		}
  		else if( colorID < 48 )		// blue-green to green
  		{
  			color->r = 0;
  			color->g = 127 + (colorID - 32) * 8;
  			color->b = 255 - (colorID - 32) * 16;
  		}
  		else if( colorID < 64 )		// green to yellow
  		{
  			color->r = (colorID - 48) * 16;
  			color->g = 255;
  			color->b = 0;
  		}
  		else if( colorID < 80 )		// yellow to orange
  		{
  			color->r = 255;
  			color->g = 255 - (colorID - 64) * 8;
  			color->b = 0;
  		}
  		else if( colorID < 96 )		// orange to red
  		{
  			color->r = 255;
  			color->g = 127 - (colorID - 80) * 8;
  			color->b = 0;
  		}
  		else if( colorID < 112 )	// red to dark-red
  		{
  			color->r = 255 - (colorID - 96) * 8;
  			color->g = 0;
  			color->b = 0;
  		}
  		else if( colorID < 128 )	// dark-red to light-pink
  		{
  			color->r = 127 + (colorID - 112) * 8;
  			color->g = (colorID - 112) * 8;
  			color->b = (colorID - 112) * 16;
  		}
  		break;
  	case 4 :	// blue to green
  	case 5 :	// inverted
  		color->r = 0;
  		color->g = colorID * 2;
  		color->b = 255 - colorID * 2;
  		break;
  	case 6 :	// green to red
  	case 7 :	// inverted
  		color->r = colorID * 2;
  		color->g = 255 - colorID * 2;
  		color->b = 0;
  		break;
  	case 8 :	// blue to red
  	case 9 :	// ...
  		color->r = colorID * 2;
  		color->g = 0;
  		color->b = 255 - colorID * 2;
  		break;
  	case 10 :	// purple to yellow
  	case 11 :
  		color->r = 255;
  		color->g = colorID * 2;
  		color->b = 255 - colorID * 2;
  		break;
  	case 12 :	// black to red
  	case 13 :
  		color->r = colorID * 2;
  		color->g = 0;
  		color->b = 0;
  		break;
  	case 14 :	// black to green
  	case 15 :
  		color->r = 0;
  		color->g = colorID * 2;
  		color->b = 0;
  		break;
  	case 16 :	// black to blue
  	case 17 :
  		color->r = 0;
  		color->g = 0;
  		color->b = colorID * 2;
  		break;
  	case 18 :	// white to red
  	case 19 :
  		color->r = 255;
  		color->g = 255 - colorID * 2;
  		color->b = 255 - colorID * 2;
  		break;
  	case 20 :	// white to green
  	case 21 :
  		color->r = 255 - colorID * 2;
  		color->g = 255;
  		color->b = 255 - colorID * 2;
  		break;
  	case 22 :	// white to blue
  	case 23 :
  		color->r = 255 - colorID * 2;
  		color->g = 255 - colorID * 2;
  		color->b = 255;
  		break;
  	case 24 :	// black to white greyscale
  	case 25 :
  		color->r = colorID * 2;
  		color->g = colorID * 2;
  		color->b = colorID * 2;
  		break;
  default :
  		color->r = colorPalette[colorID][0];
  		color->g = colorPalette[colorID][1];
  		color->b = colorPalette[colorID][2];
  	break;

}

/// if odd numbered paletteID then invert the color if( paletteID & 1) { color->r = 255 - color->r; color->g = 255 - color->g; color->b = 255 - color->b; }

Clone this wiki locally