Question: Make a function that randomly picks a pixel location, finds the color # at that location, and draws a circle at that location filled with
Make a function that randomly picks a pixel location, finds the color # at that location, and draws a circle at that location filled with that color onto the # window. The function should do this finding and drawing process 50000 times. # This will cover the old image with a artistic style. # You need to pick an x location from 0 to one less than the image width. # You need a y location from 0 to one less than the image height. # Research, using Google, the randrange function in Python and imported at the top of # this file and use it to pick a random x and a random y location. # Ask yourself, if you want to repeat the action 50000 times, what kind of loop # structure do you need? # # An example of drawing a circle to image is # # circle = Circle(Point(x, y), 5) # 5 makes a 5 pixel radius circle # circle.setFill(color) # circle.setWidth(0) # This gets rid of the circle border # circle.draw(win)
Starting Code
def photonegative_of_an_image(image): # copy the original image negative_image = image.clone() for y in range(0, image.getHeight()): for x in range(0, image.getWidth()): # get the color at location x, y color = image.getPixel(x, y) # make a negative color of the original color negative_image_color = [255 - color[0], 255 - color[1], 255 - color[2]] # set the negagive color negative_image.setPixel(x, y, negative_image_color) # return the negative_image return negative_image
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
