static Color deriveColor(Color base,Color actual,Color target){
  float[] baseHSB=Color.RGBtoHSB(base.getRed(),base.getGreen(),base.getBlue(),null);
  float[] targHSB=Color.RGBtoHSB(target.getRed(),target.getGreen(),target.getBlue(),null);
  float[] actualHSB=Color.RGBtoHSB(actual.getRed(),actual.getGreen(),actual.getBlue(),null);
  float[] resultHSB=new float[3];
  float[] finalHSB=new float[3];
  float[] diff=percentageDiff(actualHSB,baseHSB);
  resultHSB[0]=actualHSB[0] + (diff[0] * (targHSB[0] - baseHSB[0]));
  resultHSB[1]=actualHSB[1] + (diff[1] * (targHSB[1] - baseHSB[1]));
  resultHSB[2]=actualHSB[2] + (diff[2] * (targHSB[2] - baseHSB[2]));
  finalHSB[0]=saturate(resultHSB[0]);
  finalHSB[1]=saturate(resultHSB[1]);
  finalHSB[2]=saturate(resultHSB[2]);
  if (targHSB[1] > 0.1 && resultHSB[1] <= 0.1) {
    resultHSB[1]=resultHSB[2] * 0.25f;
    resultHSB[2]=resultHSB[2] - (resultHSB[2] * 0.25f);
  }
  Color result=new Color(Color.HSBtoRGB(finalHSB[0],finalHSB[1],finalHSB[2]));
  return result;
}

static Color deriveColor ( Color base , Color actual , Color target ) { float [ ] baseHSB = Color . RGBtoHSB ( base . getRed ( ) , base . getGreen ( ) , base . getBlue ( ) , null ) ; float [ ] targHSB = Color . RGBtoHSB ( target . getRed ( ) , target . getGreen ( ) , target . getBlue ( ) , null ) ; float [ ] actualHSB = Color . RGBtoHSB ( actual . getRed ( ) , actual . getGreen ( ) , actual . getBlue ( ) , null ) ; float [ ] resultHSB = new float [ 3 ] ; float [ ] finalHSB = new float [ 3 ] ; float [ ] diff = percentageDiff ( actualHSB , baseHSB ) ; resultHSB [ 0 ] = actualHSB [ 0 ] + ( diff [ 0 ] * ( targHSB [ 0 ] - baseHSB [ 0 ] ) ) ; resultHSB [ 1 ] = actualHSB [ 1 ] + ( diff [ 1 ] * ( targHSB [ 1 ] - baseHSB [ 1 ] ) ) ; resultHSB [ 2 ] = actualHSB [ 2 ] + ( diff [ 2 ] * ( targHSB [ 2 ] - baseHSB [ 2 ] ) ) ; finalHSB [ 0 ] = saturate ( resultHSB [ 0 ] ) ; finalHSB [ 1 ] = saturate ( resultHSB [ 1 ] ) ; finalHSB [ 2 ] = saturate ( resultHSB [ 2 ] ) ; if ( targHSB [ 1 ] > 0.1 && resultHSB [ 1 ] <= 0.1 ) { resultHSB [ 1 ] = resultHSB [ 2 ] * 0.25f ; resultHSB [ 2 ] = resultHSB [ 2 ] - ( resultHSB [ 2 ] * 0.25f ) ; } Color result = new Color ( Color . HSBtoRGB ( finalHSB [ 0 ] , finalHSB [ 1 ] , finalHSB [ 2 ] ) ) ; return result ; }
does the actual leg - work of deriving the color
