Turtle
017_Lines.py
import random
import os
from palettes import randomPalette
from util import getTurtleAndScreen
# Lines
# CAC, 3/27/2023
def Draw():
title = "Lines"
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)
numLines = random.randint(50,100)
lineWidth = random.randint(1,5)*(height/200)
turtle.pensize(lineWidth)
for i in range(0,numLines):
x1=random.randint(0,width)
y1=random.randint(0,height)
x2=random.randint(0,width)
y2=random.randint(0,height)
turtle.color(random.choice(colors))
turtle.penup()
turtle.goto(x1,y1)
turtle.pendown()
turtle.goto(x2,y2)
screen.mainloop()
# ----------------------------------------------------------------
if __name__ == '__main__':
Draw()
|