'''lecture_19_rainbow_image_fun.py
Create a Zelle Image with random RGB values
Oliver W. Layton
CS151: Computational Thinking: Visual Media
Fall 2020
UPDATE 1: Make rows and columns of image between 0 and 99 (inclusive) pure blue
'''
import random

import display
import graphics as gr


def setRandomRGB(img):
    for y in range(img.getHeight()):
        for x in range(img.getWidth()):
            r = random.randint(0, 255)
            g = random.randint(0, 255)
            b = random.randint(0, 255)

            img.setPixel(x, y, gr.color_rgb(r, g, b))

            # if x < 100 and y < 100:
            #     img.setPixel(x, y, gr.color_rgb(0, 0, 255))

            # if x > 200 and x < 500 and y > 50 and y < 400:
            #     img.setPixel(x, y, gr.color_rgb(255, 0, 255))   


# main code
if __name__ == '__main__':
    width = 512
    height = 256

    # Create an empty Image object
    img = gr.Image(gr.Point(0, 0), width, height)

    # Call function to set all pixels to random RGB colors
    setRandomRGB(img)

    # Display the image in a new window
    screen = display.displayImage(img, 'Our rainbow image!')

    # display image until we get a mouse click
    screen.getMouse()
