Turtle
020_Random_Circles.py
import random
import os
from drawMethods import fillCircle
from palettes import randomPalette
from util import getTurtleAndScreen
# Lines
# CAC, 3/27/2023
def Draw():
numCircles = random.randint(50,100)
title = "Circles "+str(numCircles)
width = 800
height = 600
filename = os.path.basename(__file__)[0:-3]
turtle, screen = getTurtleAndScreen(title,width,height,filename,moveWorld=True)
colors = randomPalette()
bg = random.choice(colors)
screen.bgcolor(bg)
colors.remove(bg)
radius = random.randint(20,50)
for i in range(0,numCircles):
x=random.randint(radius,width-radius)
y=random.randint(radius,height-radius)
turtle.color(random.choice(colors))
fillCircle(turtle,x,y,radius)
screen.mainloop()
# ----------------------------------------------------------------
if __name__ == '__main__':
Draw()
|