code: function whiteOrBlack( color ) {
  		color = color.replace( /^#/, '' );
  		for ( var i = 0, rgb = []; i <= 2; i++ )
  			rgb[ i ] = parseInt( color.substr( i * 2, 2 ), 16 );
  		var luma = ( 0.2126 * rgb[ 0 ] ) + ( 0.7152 * rgb[ 1 ] ) + ( 0.0722 * rgb[ 2 ] );
  		return '#' + ( luma >= 165 ? '000' : 'fff' );
  	}
docs: Basing black-white decision off of luma scheme using the Rec. 709 version