''' Module color: Purpose provide support for pixel mutation ''' def dup( p ) : ''' Returns a new pixel whose RGB values are (r, g, b), where r, g, and b are are the RGB values of p ''' r, g, b = p result = ( r, g, b ) return result def neg( p ) : ''' Returns a new pixel whose RGB values are the inverse of p, that is (255 - r, 255 - g, 255 - b), where r, g, and b are are the RGB values of p ''' r, g, b = p result = ( 255 - r, 255 - g, 255 - b ) return result def blue( p ) : ''' Returns a new pixel whose RGB values are (0, 0, b), where b is the B value of p ''' r, g, b = p result = ( 0, 0, b ) return result def bw( p ) : ''' Returns a new pixel whose RRB values are either (0, 0, 0) or (255, 255, 255). It is the former if ( r + g + b ) // 3 is less than 255 // 2; otherwise, it is the later otherwise, where r, g, and b are are the RGB values of p ''' r, g, b = p avg_level = ( r + g + b ) // 3 if ( avg_level < 255 // 2 ) : result = ( 0, 0, 0 ) else : result = ( 255, 255, 255 ) return result def grey( p ) : ''' Returns a new pixel whose RGB values are (m, m, m) where m is is the integer cast of .299r + .587g + .114b, where r, g, and b are the RGB values of p ''' pass def sepia( p ) : ''' Returns the sepia equivalent of p according to the homework specification ''' pass def distance( p1, p2 ) : ''' Returns the distance between p1 and p2; that is the sum of the red differences, green differences, and blue differences, where difference is an absolute value ''' pass PALETTE8 = [ ( 0, 0, 0), (255,255,255), ( 0,255, 0), ( 0, 0,255), (255, 0, 0), (255,255, 0), (255, 0,255), ( 0,255,255) ] def simplify( p ) : ''' Returns the pixel in PALETTE8 that p is closest too ''' pass