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

Color is defined in the node table with:

  • 8bit (0-255) RGBA components: color_r, color_g, color_b & color_a.
  • User can manually change the color based on: palette_id & color_id.
  • Press '-' or '+' key to change color_id.
  • Press ALT+'-' or ALT+'+' to change palette_id.

*Note that the (color_a) alpha Transparency level is NOT effected when switching colors.

Users can also set custom colors (not based on palette ID's), in which case the RGBA color will (usually) NOT correspond with the palette and color ID's. This also means that in the GUI if you change either palette_id or color_id of a node then the custom RGB color is not retained..

Another exception is with 3D models, changing geometry to a custom 3D model will temporarily 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 the node back to the set of hard-coded (geo) primitives, the color will return to its original values.


26 Color Palettes Defined

There are several hard-coded palettes:

  • palette_id = 0 is a distinct set of 20 colors.
  • palette_id's 1-25 are gradients with 256 color_id's each (0-255).
  • Odd palette_id's are inverted colors (mirrors) of their Even numbered predecessor.
  • 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).

Color Palette Code

  • 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