'''Generate a color gray gradient image''' # import the Pillow Image type from PIL import Image import random def graydient( ) : ''' Return a gray gradient of dimensions 255 by 255 ''' w = 255 h = 255 # create a blank canvas on which to paint our image im = Image.new( 'RGB', ( w, h ) ) # consider every spot (pixel) on the new image for x in range( 0, w ) : for y in range( 0, h ) : # got coordinate of interest coord = ( x, y ) # generate the color for the pixel pixel = ( x, x, x ) # set pixel color at coordinate of interest im.putpixel( coord, pixel ) return im if ( __name__ == '__main__' ) : gradient = graydient( ) gradient.show()