Turtle
039_GradientParialCircles.py
import random
import os
from drawMethods import drawGradientCircle, fillCircle
from palettes import randomPalette
from util import getTurtleAndScreen
# Gradients
# CAC, 4/17/2023
def Draw():
width = 800
height = 600
cellSize = 25*random.randint(1,10)
radius = cellSize//2
cols = width//cellSize
rows = height//cellSize
number = random.randint(3,9)
title = "Gradient Circles "+str(number)+" Charles Cusack, 2023"
filename = os.path.basename(__file__)[0:-3]
turtle, screen = getTurtleAndScreen(title, width, height, filename, moveWorld=True)
colors = randomPalette()
bg = random.choice(colors)
if random.randint(0,1):
colors.remove(bg)
screen.bgcolor(bg)
drawBackCircle = random.randint(0,1)
for row in range(rows):
for col in range(cols):
x = cellSize*col+radius
y = cellSize*row+radius
color1=random.choice(colors)
color2=random.choice(colors)
while (color2 == color1):
color2 = random.choice(colors)
ext = random.randint(210,360)
s = random.randint(0,359)
if drawBackCircle:
turtle.color(color1)
fillCircle(turtle,x,y,radius)
drawGradientCircle(turtle, x, y, radius, number, color1, color2,
extent = ext, start = s)
turtle.penup()
print(str(screen.window_height())+" "+str(screen.window_width()))
screen.mainloop()
# ----------------------------------------------------------------
if __name__ == '__main__':
Draw()
|