""" random_circles.py Draw many circles which vary somewhat slowly in location, size, and color. Jim M | cs.marlboro.college | Sep 2018 | MIT LIcense """ from graphics import * from random import randint n_circles = 1000 window_size = 800 # pixels, width & height initial_radius = 20 # pixels position_shift = 80 # pixels, max random location change radius_shift = 10 # pixels, max random radius chnage initial_red = 200 initial_green = 200 initial_blue = 200 color_shift = 4 # max random color change def circles(): window = GraphWin("random circles ...", window_size, window_size) x = window_size/2 y = window_size/2 radius = initial_radius red = initial_red green = initial_green blue = initial_blue for i in range(n_circles): circle = Circle(Point(x, y), radius) color = color_rgb(red, green, blue) circle.setFill(color) circle.setOutline(color) circle.draw(window) x = (x + randint(-position_shift, position_shift)) % window_size y = (y + randint(-position_shift, position_shift)) % window_size red = (red + randint(-color_shift, color_shift)) % 256 green = (green + randint(-color_shift, color_shift)) % 256 blue = (blue + randint(-color_shift, color_shift)) % 256 done = input("done? ") circles()