Esempio n. 1
0
col4 IDManager::getColorFromObject(const void* obj) {
    if (obj == 0)
        return col4(0,0,0,0);

    if (isRegistered(obj))
        return IDToColor_[obj];
    else
        return col4(0,0,0,0);
}
TEST(PaletteTranslator, BuildSortLuminance)
{
	//uint32 y = r * 299 + g * 587 + b * 114;

	Color col0(0, 0, 10);
	Color col1(0, 0, 11);
	Color col2(10, 0, 0);
	Color col3(11, 0, 0);
	Color col4(0, 10, 0);
	Color col5(0, 11, 0);

	Palette pal;
	pal.m_count = 6;
	pal[0] = col3;
	pal[1] = col5;
	pal[2] = col1;
	pal[3] = col2;
	pal[4] = col4;
	pal[5] = col0;

	Palette exp;
	exp.m_count = 6;
	exp[0] = col0;
	exp[1] = col1;
	exp[2] = col2;
	exp[3] = col3;
	exp[4] = col4;
	exp[5] = col5;

	PaletteTranslator pt;
	pt.BuildSortLuminance(pal, nullptr);

	ASSERT_TRUE( pal == exp );
}
Esempio n. 3
0
col4 IDManager::getColorFromId(int id) {
    if(id < 0)
        return col4(0,0,0,0);

    if(id > 16777216) {
        LERRORC("voreen.IDManager", "id to big!");
        return col4(0,0,0,0);
    }

    col4 c;
    c.b = id & 255;
    c.g = (id >> 8) & 255;
    c.r = (id >> 16) & 255;
    c.a = 255;
    return c;
}
Esempio n. 4
0
Matrix4 Matrix4::multiply(Matrix4 a)
{
    Matrix4 b;
  /*
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			b.m[i][j] = m[0][j] * a.m[i][0] + m[1][j] * a.m[i][1] + m[2][j] * a.m[i][2] + m[3][j] * a.m[i][3];
		}
	}*/
	Vector4 row1(m[0][0], m[1][0], m[2][0], m[3][0]);
	Vector4 row2(m[0][1], m[1][1], m[2][1], m[3][1]);
	Vector4 row3(m[0][2], m[1][2], m[2][2], m[3][2]);
	Vector4 row4(m[0][3], m[1][3], m[2][3], m[3][3]);

	Vector4 col1(a.m[0][0], a.m[0][1], a.m[0][2], a.m[0][3]);
	Vector4 col2(a.m[1][0], a.m[1][1], a.m[1][2], a.m[1][3]);
	Vector4 col3(a.m[2][0], a.m[2][1], a.m[2][2], a.m[2][3]);
	Vector4 col4(a.m[3][0], a.m[3][1], a.m[3][2], a.m[3][3]);

	b.set(row1.dot(col1), row2.dot(col1), row3.dot(col1), row4.dot(col1),
		row1.dot(col2), row2.dot(col2), row3.dot(col2), row4.dot(col2),
		row1.dot(col3), row2.dot(col3), row3.dot(col3), row4.dot(col3),
		row1.dot(col4), row2.dot(col4), row3.dot(col4), row4.dot(col4));

    return b;
}
Esempio n. 5
0
void door(void) {
    initLeds();
    col1();
    col4();
    col7();
    _delay_ms(200);
    col1();
    col5();
    col9();
    _delay_ms(200);
    col1();
    col2();
    col3();
    _delay_ms(200);
}
TEST(PaletteTranslator, BuildDuplicatedColors)
{
	Color col0(11, 12, 13);
	Color col1(14, 15, 16);
	Color col2(20, 21, 22, 0);
	Color col3(11, 12, 13);
	Color col4(30, 31, 32, 0);

	Palette pal;
	pal.m_count = 5;
	pal[0] = col0;
	pal[1] = col1;
	pal[2] = col2;
	pal[3] = col3;
	pal[4] = col4;

	Palette exp;
	exp.m_count = 3;
	exp[0] = col0;
	exp[1] = col1;
	exp[2] = col2;

	uint32 colCounts[256] = { 1, 10, 100, 1000, 10000 };
	uint32 expectedColCounts[256] = { 1001, 10, 10100, 0, 0 };

	PaletteTranslator pt;
	pt.BuildDuplicatedColors(pal, colCounts);
	ASSERT_TRUE( pal == exp );
	ASSERT_TRUE( memcmp(colCounts, expectedColCounts, sizeof(colCounts)) == 0 );

	uint8 pixels[] = { 0, 1, 2, 3, 4 };
	const uint8 expectedPixels[] = { 0, 1, 2, 0, 2 };
	
	pt.Translate(pixels, sizeof(pixels));
	
	ASSERT_TRUE( memcmp(pixels, expectedPixels, sizeof(pixels)) == 0 );
}
Esempio n. 7
0
void    GLUI_Translation::draw_2d_arrow( int radius, int filled, int orientation )
{
  float x1 = .2, x2 = .4, y1 = .54, y2 = .94, y0;
  float x1a, x1b;
  vec3  col1( 0.0, 0.0, 0.0 ), col2( .45, .45, .45 ), 
    col3( .7, .7, .7 ), col4( 1.0, 1.0, 1.0 );
  vec3  c1, c2, c3, c4, c5, c6;
  vec3  white(1.0,1.0,1.0), black(0.0,0.0,0.0), gray(.45,.45,.45), 
    bkgd(.7,.7,.7);
  int   c_off; /* color index offset */

  if ( glui )
    bkgd.set(glui->bkgd_color_f[0],
	     glui->bkgd_color_f[1],
	     glui->bkgd_color_f[2]);

  /*	bkgd[0] = 255.0; bkgd[1] = 0;              */

  /** The following 8 colors define the shading of an octagon, in
    clockwise order, starting from the upstroke on the left  **/
  /** This is for an outside and inside octagons **/
  vec3 colors_out[]={white, white, white, gray, black, black, black, gray};
  vec3 colors_in[] ={bkgd,white,bkgd,gray,gray,gray,gray,gray};

#define SET_COL_OUT(i) glColor3fv((float*) &colors_out[(i)%8][0]);
#define SET_COL_IN(i) glColor3fv((float*) &colors_in[(i)%8][0]);

  x1 = (float)radius * .2;
  x2 = x1 * 2;
  y1 = (float)radius * .54;
  y2 = y1 + x2;
  x1a = x1;
  x1b = x1;

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();

#define DRAW_SEG( xa,ya,xb,yb ) glVertex2f(xa,ya); glVertex2f(xb,yb);

  glScalef( -1.0, 1.0, 1.0 );
	
  if ( orientation == 2 ) {
    c_off = 4;
  }
  else if ( orientation == 0 ) {
    c_off = 0;
    glRotatef( 180.0, 0.0, 0.0, 1.0 );
  }
  else if ( orientation == 1 ) {
    c_off = 2;
    glRotatef( 90.0, 0.0, 0.0, 1.0 );
  }
  else if ( orientation == 3 ) {
    c_off = 6;
    glRotatef( -90.0, 0.0, 0.0, 1.0 );
  }

  if ( trans_type == GLUI_TRANSLATION_Z )
    y0 = 0.0;
  else if ( trans_type == GLUI_TRANSLATION_XY )
    y0 = x1;
  else
    y0 = 0.0;

	
  if ( trans_type == GLUI_TRANSLATION_Z ) {
    if ( orientation == 0 ) {
      y1 += 2.0;
      y2 += 0.0;

      x1b -= 2.0;
      x2  -= 2.0;
      x1a += 2.0;
    }
    else if ( orientation == 2 ) {
      y1 -= 6.0;
      x1a += 2.0;
      x1b += 4.0;
      x2  += 6.0; 
    }
  }

  /*** Fill in inside of arrow  ***/
  if ( NOT filled ) {  /*** Means button is up - control is not clicked ***/
    /*glColor3f( .8, .8, .8 );              */
    set_to_bkgd_color();
    glColor3f( bkgd[0]+.07, bkgd[1]+.07, bkgd[2]+.07 );
  }
  else {               /*** Button is down on control ***/
    glColor3f( .6, .6, .6 );
    c_off += 4;  /* Indents the shadows - goes from a raised look to embossed */
  }

  /*** Check if control is enabled or not ***/
  if ( NOT enabled ) {
    set_to_bkgd_color();
    /*c_off += 4;  -- Indents the shadows - goes from a raised look to embossed */              
    colors_out[0] = colors_out[1] = colors_out[2] = colors_out[7] = gray;
    colors_out[3] = colors_out[4] = colors_out[5] = colors_out[6] = white;
    colors_in[0] = colors_in[1] = colors_in[2] = colors_in[7] = white;
    colors_in[3] = colors_in[4] = colors_in[5] = colors_in[6] = gray;
	
  }

  glBegin( GL_POLYGON );
  glVertex2f( 0.0, 0.0  );  glVertex2f( -x1a, 0.0 );
  glVertex2f( -x1a, 0.0   );  glVertex2f( -x1b, y1 );
  glVertex2f( x1b, y1);      glVertex2f( x1a, 0.0 );
  glVertex2f( x1a, 0.0 );     glVertex2f( 0.0, 0.0  );
  glEnd();
  glBegin( GL_TRIANGLES );
  glVertex2f( -x2, y1 ); glVertex2f( 0.0, y2 ); glVertex2f( x2, y1 );
  glEnd();

  glLineWidth( 1.0 );
  /*** Draw arrow outline ***/
  glBegin( GL_LINES );

  SET_COL_IN(1+c_off);  DRAW_SEG( 0.0, y2-1.0, -x2, y1-1.0 );
  SET_COL_IN(6+c_off);	DRAW_SEG( -x2+2.0, y1+1.0, -x1b+1.0, y1+1.0 );
  SET_COL_IN(0+c_off);	DRAW_SEG( -x1b+1.0, y1+1.0, -x1a+1.0, y0 );
  SET_COL_IN(3+c_off);	DRAW_SEG( 0.0, y2-1.0, x2, y1-1.0 );
  SET_COL_IN(6+c_off);	DRAW_SEG( x2-1.0, y1+1.0, x1b-1.0, y1+1.0 );
  SET_COL_IN(4+c_off);	DRAW_SEG( x1b-1.0, y1+1.0, x1a-1.0, y0 );

  SET_COL_OUT(0+c_off);  DRAW_SEG( -x1a, y0, -x1b, y1  );
  SET_COL_OUT(6+c_off);  DRAW_SEG( -x1b, y1,  -x2, y1  );
  SET_COL_OUT(1+c_off);  DRAW_SEG( -x2, y1,  0.0, y2  );
  SET_COL_OUT(3+c_off);  DRAW_SEG( 0.0, y2,   x2, y1  );
  SET_COL_OUT(6+c_off);  DRAW_SEG(  x2, y1,   x1b, y1  );
  SET_COL_OUT(4+c_off);  DRAW_SEG(  x1b, y1,   x1a, y0 );

  glEnd();

#undef DRAW_SEG

  glPopMatrix();
}
Esempio n. 8
0
void IDManager::clearRegisteredObjects() {
    colorToID_.clear();
    IDToColor_.clear();
    currentID_ = col4(0,0,0,255);
}
Esempio n. 9
0
void Board::Initialise()
{
	float zbase = 400;							//  Variable to store how deep in the z axis the object is based.
	
	
	Vector4 temp1(-600, 800, 1200 + zbase, 1);
	Vector4 temp2(600, 800, 1200 + zbase, 1);
	Vector4 temp3(600, 800, 0 + zbase, 1);
	Vector4 temp4(-600,800,0 + zbase,1);
	top.Initialise(temp1, temp2, temp3, temp4);		//  Set individual vertex locations for the top face of the board
	
	Vector4 col1(70,50,4,1);
	Vector4 col2(92,67,5,1);
	Vector4 col3(102,75,6,1);
	Vector4 col4(119,77,0,1);
	Vector4 col5(69, 25, 18, 1);
	top.SetColours(col1, col2, col2, col3);			//  Set individual colour values of each of those vertices
	
	
	
	Vector4 temp5(-600, 800, 0 + zbase, 1);
	Vector4 temp6(600, 800, 0 + zbase, 1);
	Vector4 temp7(600, 1000, 0 + zbase, 1);
	Vector4 temp8(-600,1000, 0 + zbase,1);			//  Individual vertices for the front face
	
	Vector4 temp9(-800, 1000, 1200 + zbase + 300, 1);
	Vector4 temp10(800, 1000, 1200 + zbase + 300, 1);
	Vector4 temp11(800, 1000, 100, 1);
	Vector4 temp12(-800, 1000, 100,1);				//  Individual vertices for the base face
	table.Initialise(temp9, temp10, temp11, temp12);
	table.SetColours(col5, col5, col5, col5);		//  Set to one mat colour, no shading.
	
	Vector4 temp13(-600, 800, 1200 + zbase, 1);
	Vector4 temp14(-600, 800, 0 + zbase, 1);
	Vector4 temp15(-600, 1000, 0 + zbase, 1);
	Vector4 temp16(-600, 1000, 1200 + zbase, 1);	//  Set individual vertices for the left face
	
	Vector4 temp17(600, 800, 0 + zbase, 1);
	Vector4 temp18(600, 800, 1200 + zbase, 1);
	Vector4 temp19(600, 1000, 1200 + zbase, 1);
	Vector4 temp20(600, 1000, 0 + zbase, 1);		//  Set individual vertices for the right face

	sides[0].Initialise(temp5, temp6, temp7, temp8);
	sides[1].Initialise(temp13, temp14, temp15, temp16);
	sides[2].Initialise(temp17, temp18, temp19, temp20);
	sides[3].Initialise(temp2, temp1, temp16, temp19);		//  Use known vertices to initialise the side faces
	
	sides[0].SetColours(col3, col4, col4, col2);
	sides[1].SetColours(col1, col2, col2, col1);
	sides[2].SetColours(col2, col1, col1, col2);
	sides[3].SetColours(col4, col4, col4, col4);			//  Then set the colours
	
	
	float positionLocations[24][2] =   {{-450, 1050 + zbase},		//1					An array holding the centre locations
										{-300,  900 + zbase},		//2					of each of the positions where pieces
										{-150,  750 + zbase},		//3					can be placed.
										{  0 ,  750 + zbase},		//4
										{ 150,  750 + zbase},		//5
										{ 300,  900 + zbase},		//6
										{ 450, 1050 + zbase},		//7
										{  0 ,  900 + zbase},		//8
										{  0 , 1050 + zbase},		//9
										{-450,  600 + zbase},		//10
										{-300,  600 + zbase},		//11
										{-150,  600 + zbase},		//12
										{-450,  150 + zbase},		//13
										{-300,  300 + zbase},		//14
										{-150,  450 + zbase},		//15
										{  0 ,  150 + zbase},		//16
										{  0 ,  300 + zbase},		//17
										{  0 ,  450 + zbase},		//18
										{ 450,  150 + zbase},		//19
										{ 300,  300 + zbase},		//20
										{ 150,  450 + zbase},		//21
										{ 450,  600 + zbase},		//22
										{ 300,  600 + zbase},		//23
										{ 150,  600 + zbase}};		//24
	for (int i = 0; i < 24; i++) {									
		boardpositions[i].Initialise(positionLocations[i][0], positionLocations[i][1]);			//  Create the individual graphical representations
	}																							//  (class Position) and put in array for easy drawing.
	InitialiseLines();				//  Ugly function to draw each and every line on the
									//  board with individual hand-placed vertices.
									
	SetupMills();					//  Set up the mills (groups of three) with pointers to the positions
									//  as alternate referencing option
	
}