une image de la version de l'enseignant ci-dessous (à vous de faire mieux !)
le code de la fonction colorDist()
/** CALCULATES A 'DISTANCE' BETWEEN TWO COLORS dist=0.0 should mean the very same color. distance between black and white should be 1 distance between opaque and transparent color should be 1 from: http://stackoverflow.com/questions/5066439/compare-pixel-colour-java with alpha and normalisation added ***/float colorDist(color c1, color c2) {
float rmean =(red(c1) + red(c2)) / 2;
float r = red(c1) - red(c2);
float g = green(c1) - green(c2);
float b = blue(c1) - blue(c2);
float a = (alpha(c1) - alpha(c2))/255.0;
return Math.max(a, sqrt((int(((512+rmean)*r*r))>>8)+(4*g*g)+(int(((767-rmean)*b*b))>>8))/764.8333);
} // colorDist()