Changeset 1116
- Timestamp:
- Aug 18, 2008, 2:04:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/transfer-function/ColorPaletteWindow.cpp
r1113 r1116 553 553 GLfloat rainbowColor[21] = {1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0}; 554 554 555 int pos = floor(x/unitWidth);556 int red_left = rainbowColor[3*pos];557 int red_right = rainbowColor[3*(pos+1)];558 559 int green_left = rainbowColor[3*pos+1];560 int green_right = rainbowColor[3*(pos+1)+1];561 562 int blue_left = rainbowColor[3*pos+2];563 int blue_right = rainbowColor[3*(pos+1)+2];555 int pos = (int)floor(x/unitWidth); 556 int red_left = (int)rainbowColor[3*pos]; 557 int red_right = (int)rainbowColor[3*(pos+1)]; 558 559 int green_left = (int)rainbowColor[3*pos+1]; 560 int green_right = (int)rainbowColor[3*(pos+1)+1]; 561 562 int blue_left = (int)rainbowColor[3*pos+2]; 563 int blue_right = (int)rainbowColor[3*(pos+1)+2]; 564 564 565 565 double r, g, b; 566 r = (red_left+((float)x/(float)unitWidth-pos)*(red_right-red_left)); 567 g = (green_left+((float)x/(float)unitWidth-pos)*(green_right-green_left)); 568 b = (blue_left+((float)x/(float)unitWidth-pos)*(blue_right-blue_left)); 569 570 cp_color_r=255*r; 571 cp_color_g=255*g; 572 cp_color_b=255*b; 573 566 r = (red_left+(x/unitWidth-pos)*(red_right-red_left)); 567 g = (green_left+(x/unitWidth-pos)*(green_right-green_left)); 568 b = (blue_left+(x/unitWidth-pos)*(blue_right-blue_left)); 569 570 cp_color_r = (int)(255.0*r); 571 cp_color_g = (int)(255.0*g); 572 cp_color_b = (int)(255.0*b); 574 573 575 574 cp_glui->sync_live(); … … 584 583 b = t; 585 584 586 cp_color_r =255*r;587 cp_color_g =255*g;588 cp_color_b =255*b;585 cp_color_r = (int)(255.0*r); 586 cp_color_g = (int)(255.0*g); 587 cp_color_b = (int)(255.0*b); 589 588 590 589 cp_glui->sync_live(); … … 598 597 GLfloat rainbowColor[21] = {1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0}; 599 598 600 int pos = floor(x/unitWidth);601 int red_left = rainbowColor[3*pos];602 int red_right = rainbowColor[3*(pos+1)];603 604 int green_left = rainbowColor[3*pos+1];605 int green_right = rainbowColor[3*(pos+1)+1];606 607 int blue_left = rainbowColor[3*pos+2];608 int blue_right = rainbowColor[3*(pos+1)+2];599 int pos = (int)floor(x/unitWidth); 600 int red_left = (int)rainbowColor[3*pos]; 601 int red_right = (int)rainbowColor[3*(pos+1)]; 602 603 int green_left = (int)rainbowColor[3*pos+1]; 604 int green_right = (int)rainbowColor[3*(pos+1)+1]; 605 606 int blue_left = (int)rainbowColor[3*pos+2]; 607 int blue_right = (int)rainbowColor[3*(pos+1)+2]; 609 608 610 609 611 r = (red_left+( (float)x/(float)unitWidth-pos)*(red_right-red_left));612 g = (green_left+( (float)x/(float)unitWidth-pos)*(green_right-green_left));613 b = (blue_left+( (float)x/(float)unitWidth-pos)*(blue_right-blue_left));614 615 cp_color_H= 360*((double)x/(double)cp_winx);610 r = (red_left+(x/unitWidth-pos)*(red_right-red_left)); 611 g = (green_left+(x/unitWidth-pos)*(green_right-green_left)); 612 b = (blue_left+(x/unitWidth-pos)*(blue_right-blue_left)); 613 614 cp_color_H= (int)(360.0*(x/(double)cp_winx)); 616 615 617 616 hue_color->R=r; … … 621 620 } 622 621 else{ 623 cp_color_S= 100*(1-(double)color_point_1->x/(double)cp_winx);624 cp_color_B= 100*((double)(color_point_1->y-(double)(2*cp_winy/3))/((double)cp_winy/3));622 cp_color_S=(int)(100.0*(1-(double)color_point_1->x/(double)cp_winx)); 623 cp_color_B=(int)(100.0*((double)(color_point_1->y-(double)(2*cp_winy/3))/((double)cp_winy/3))); 625 624 } 626 625 … … 630 629 //upper left: (1,1,1) 631 630 //upper right: hue color 632 r= (double)1+(double)color_point_1->x/((double)cp_winx)*(double)(hue_color->R-1);633 g= (double)1+(double)color_point_1->x/((double)cp_winx)*(double)(hue_color->G-1);634 b= (double)1+(double)color_point_1->x/((double)cp_winx)*(double)(hue_color->B-1);631 r=1.0+(double)color_point_1->x/((double)cp_winx)*(double)(hue_color->R-1); 632 g=1.0+(double)color_point_1->x/((double)cp_winx)*(double)(hue_color->G-1); 633 b=1.0+(double)color_point_1->x/((double)cp_winx)*(double)(hue_color->B-1); 635 634 636 635 //2. vertical interpolation: 637 636 //buttom (0,0,0) 638 r=(double)r+((double)cp_winy-(double)color_point_1->y)/((double)cp_winy/3)*((double)(0-r)); 639 g=(double)g+((double)cp_winy-(double)color_point_1->y)/((double)cp_winy/3)*((double)(0-g)); 640 b=(double)b+((double)cp_winy-(double)color_point_1->y)/((double)cp_winy/3)*((double)(0-b)); 641 642 cp_color_r=255*r; 643 cp_color_g=255*g; 644 cp_color_b=255*b; 645 646 637 r += ((double)cp_winy-(double)color_point_1->y)/((double)cp_winy/3)*(-r); 638 g += ((double)cp_winy-(double)color_point_1->y)/((double)cp_winy/3)*(-g); 639 b += ((double)cp_winy-(double)color_point_1->y)/((double)cp_winy/3)*(-b); 640 641 cp_color_r = (int)(255.0*r); 642 cp_color_g = (int)(255.0*g); 643 cp_color_b = (int)(255.0*b); 647 644 648 645 //printf("(%d,%d,%d) ", cp_color_r, cp_color_g, cp_color_b);
Note: See TracChangeset
for help on using the changeset viewer.