private int colorWheelLocationToRGB(int x,int y,double rad){
  double angle=Math.acos((double)x / rad);
  int rgb;
  if (angle < PI_3) {
    if (y < 0) {
      rgb=0xFF0000 | Math.min(255,(int)(255 * angle / PI_3)) << 8;
    }
 else {
      rgb=0xFF0000 | Math.min(255,(int)(255 * angle / PI_3));
    }
  }
 else   if (angle < 2 * PI_3) {
    angle-=PI_3;
    if (y < 0) {
      rgb=0x00FF00 | Math.max(0,255 - (int)(255 * angle / PI_3)) << 16;
    }
 else {
      rgb=0x0000FF | Math.max(0,255 - (int)(255 * angle / PI_3)) << 16;
    }
  }
 else {
    angle-=2 * PI_3;
    if (y < 0) {
      rgb=0x00FF00 | Math.min(255,(int)(255 * angle / PI_3));
    }
 else {
      rgb=0x0000FF | Math.min(255,(int)(255 * angle / PI_3)) << 8;
    }
  }
  return rgb;
}

private int colorWheelLocationToRGB ( int x , int y , double rad ) { double angle = Math . acos ( ( double ) x / rad ) ; int rgb ; if ( angle < PI_3 ) { if ( y < 0 ) { rgb = 0xFF0000 | Math . min ( 255 , ( int ) ( 255 * angle / PI_3 ) ) << 8 ; } else { rgb = 0xFF0000 | Math . min ( 255 , ( int ) ( 255 * angle / PI_3 ) ) ; } } else if ( angle < 2 * PI_3 ) { angle -= PI_3 ; if ( y < 0 ) { rgb = 0x00FF00 | Math . max ( 0 , 255 - ( int ) ( 255 * angle / PI_3 ) ) << 16 ; } else { rgb = 0x0000FF | Math . max ( 0 , 255 - ( int ) ( 255 * angle / PI_3 ) ) << 16 ; } } else { angle -= 2 * PI_3 ; if ( y < 0 ) { rgb = 0x00FF00 | Math . min ( 255 , ( int ) ( 255 * angle / PI_3 ) ) ; } else { rgb = 0x0000FF | Math . min ( 255 , ( int ) ( 255 * angle / PI_3 ) ) << 8 ; } } return rgb ; }
returns the rgb color to use for the specified location . the passed in point must be on the color wheel and be relative to the origin of the color wheel .
