At Westonci.ca, we make it easy to get the answers you need from a community of informed and experienced contributors. Get quick and reliable answers to your questions from a dedicated community of professionals on our platform. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.

PLEASE HELP ME FIX THIS CODE.

I WANT IT TO HAVE USER INPUT TO CHANGE AND IMAGE FILTER TO BLUE RED OR GREEN.


user_color = input("What color would you like to paint the canvas, blue, red or green?:")



def user_red(pixel):
pixel[0] = 100 + pixel[0]
pixel[1] = 100 - pixel[1]
pixel[2] = 100 - pixel[2]

return pixel

def user_green(pixel):
pixel[0] = 100 + pixel[0]
pixel[1] = 100 - pixel[1]
pixel[2] = 100 - pixel[2]

return pixel

def user_blue(pixel):
pixel[0] = 100 + pixel[0]
pixel[1] = 100 - pixel[1]
pixel[2] = 100 - pixel[2]

return pixel


def custom_filter(image, user_color):
for x in range(image.get_width()):
for y in range(image.get_height()):
pixel = image.get_pixel(x,y)
new_colors = invert_pixel(pixel)
image.set_red(x, y, new_colors[0])
image.set_green(x, y, new_colors[1])
image.set_blue(x, y, new_colors[2])



return image


def change_image():
global image
image = custom_filter(image, user_color)



timer.set_timeout(change_image, IMAGE_LOAD_TIME)

Sagot :

PLEASE HELP ME FIX THIS CODE.

I WANT IT TO HAVE USER INPUT TO CHANGE AND IMAGE FILTER TO BLUE RED OR GREEN.

user_color = input("What color would you like to paint the canvas, blue, red or green?:")

def user_red(pixel):

pixel[0] = 100 + pixel[0]

pixel[1] = 100 - pixel[1]

pixel[2] = 100 - pixel[2]

return pixel

def user_green(pixel):

pixel[0] = 100 + pixel[0]

pixel[1] = 100 - pixel[1]

pixel[2] = 100 - pixel[2]

return pixel

def user_blue(pixel):

pixel[0] = 100 + pixel[0]

pixel[1] = 100 - pixel[1]

pixel[2] = 100 - pixel[2]

return pixel

def custom_filter(image, user_color):

for x in range(image.get_width()):

for y in range(image.get_height()):

pixel = image.get_pixel(x,y)

new_colors = invert_pixel(pixel)

image.set_red(x, y, new_colors[0])

image.set_green(x, y, new_colors[1])

image.set_blue(x, y, new_colors[2])

return image

def change_image():

global image

image = custom_filter(image, user_color)

timer.set_timeout(change_image, IMAGE_LOAD_TIME)