#include "color_table.h"



namespace Global {

	Colorf color_from_table(unsigned int index) {
		if((255 < index) && (index <= 512)) 
			index = 512 - index;
		if((512 < index) && (index <= 768)) 
			index = index - 512;
		if(index > 768) 
			index = 1024-index;

		if(index < 0) 
			index = 0;
		if(index > 255) 
			index = 255;

		// colored
		float r = static_cast<float>(g_color_table[index][0]) ;
		float g = static_cast<float>(g_color_table[index][1]) ;
		float b = static_cast<float>(g_color_table[index][2]) ;

		return (Colorf(r, g, b, 1.0f));
	} 

	Colorf random_color() {
		float r = (rand()%256) / 255.0f;
		float g = (rand()%256) / 255.0f;
		float b = (rand()%256) / 255.0f;
		return Colorf(r, g, b, 0.5f);
	}

	Colorf random_color_from_table() {
		int random_int = rand() / 256;
		return color_from_table(random_int);
	}

}
