Joseph Drackey

Generation

generate functionTue, 28 Mar 2023

Converts an image to grayscale using the crude average of the r, g, and b

def grayscale(image): width = image.get_width() height = image.get_height() newImage = pg.Surface((width, height)) for y in range(height): for x in range(width): r,g,b = image.get_at((x,y)) newImage.set_at((x,y), (int((r+g+b)/3), int((r+g+b)/3), int((r+g+b)/3))) return newImage

Questions about programming?Chat with your personal AI assistant