void findClosestColor( int red, int green, int blue, int alpha, ClosestColor closest ) {
if ( this.numChildren > 0 )
for ( int id = 0; id < MAX_CHILDREN; id++ )
if ( this.children[id] != null )
this.children[id].findClosestColor( red, green, blue, alpha, closest );
if ( this.uniqueCount != 0 ) {
int dr = ( this.cube.colorMap[0][this.colorIndex] & 0xff ) - red;
int dg = ( this.cube.colorMap[1][this.colorIndex] & 0xff ) - green;
int db = ( this.cube.colorMap[2][this.colorIndex] & 0xff ) - blue;
int da = ( this.cube.colorMap[3][this.colorIndex] & 0xff ) - alpha;
int distance = da * da + dr * dr + dg * dg + db * db;
if ( distance < closest.distance ) {
closest.distance = distance;
closest.colorIndex = this.colorIndex;
}
}
}