generated from mwc/project_drawing
188 lines
2.7 KiB
Python
188 lines
2.7 KiB
Python
# drawing.py
|
|
# ----------
|
|
# By Kathryn Odell-Hamilton
|
|
#
|
|
# (Briefly describe what this program does.)
|
|
"""The program will create a grid of draw black varying weight lines horizontally and vertically fully and partially
|
|
across to create one fill square and two fill rectangles in a Piet Mondrian abstract artistic style. Within the layout
|
|
a few shapes (squares and rectangles) will be drawn and filled with primary colors, red, blue, yellow.
|
|
"""
|
|
|
|
from turtle import *
|
|
|
|
screensize(500, 500)
|
|
speed(9)
|
|
|
|
# Positioning pen in upper left of screen
|
|
penup()
|
|
setposition(-200, 200)
|
|
|
|
# Pen color and size
|
|
pendown()
|
|
# pen color and size
|
|
pencolor("black")
|
|
pensize(2)
|
|
|
|
|
|
# Drawing a square
|
|
def square(side_length):
|
|
for side in range(4):
|
|
forward(side_length)
|
|
right(90)
|
|
|
|
sizes = [400]
|
|
|
|
for size in sizes:
|
|
square(size)
|
|
penup()
|
|
|
|
|
|
# Move down on left side
|
|
right(90)
|
|
forward(170)
|
|
left(90)
|
|
|
|
# Drawing horizontal lines
|
|
forward(2)
|
|
pencolor("black")
|
|
pensize(6)
|
|
pendown()
|
|
forward(396)
|
|
|
|
#Return to left side and down
|
|
penup()
|
|
left(180)
|
|
forward(397)
|
|
|
|
# Move down on left side
|
|
left(90)
|
|
forward(90)
|
|
left(90)
|
|
|
|
# Drawing horizontal lines
|
|
forward(1)
|
|
pendown()
|
|
forward(396)
|
|
|
|
#Return to left side and down
|
|
penup()
|
|
left(180)
|
|
forward(397)
|
|
|
|
# Move down on left side
|
|
left(90)
|
|
forward(130)
|
|
left(90)
|
|
|
|
# Drawing horizontal lines
|
|
forward(-1)
|
|
pendown()
|
|
pensize(3)
|
|
forward(398)
|
|
|
|
#Return to left side and down
|
|
penup()
|
|
left(180)
|
|
forward(400)
|
|
|
|
# draw vertical line from 2nd horizontal line
|
|
pensize(3.5)
|
|
right(90)
|
|
forward(130)
|
|
right(90)
|
|
forward(50)
|
|
right(90)
|
|
pendown()
|
|
forward(130)
|
|
|
|
# Move up to top position to draw vertical line
|
|
penup()
|
|
left(180)
|
|
forward(388)
|
|
right(90)
|
|
forward(140)
|
|
right(90)
|
|
|
|
# Draw 2nd vertical line from top to bottom line
|
|
pendown()
|
|
pensize(4)
|
|
forward(387)
|
|
|
|
# Draw 3rd vertical line from 2nd horizontal line to bottom line
|
|
penup()
|
|
left(180)
|
|
forward(128)
|
|
right(90)
|
|
|
|
|
|
# Drawing a blue square
|
|
pendown()
|
|
fillcolor('blue')
|
|
begin_fill()
|
|
def square(side_length):
|
|
for side in range(4):
|
|
forward(side_length)
|
|
right(90)
|
|
|
|
sizes = [105]
|
|
|
|
for size in sizes:
|
|
square(size)
|
|
|
|
end_fill()
|
|
|
|
#3rd vertical line
|
|
penup()
|
|
forward(105)
|
|
right(90)
|
|
pendown()
|
|
forward(128)
|
|
left(90)
|
|
|
|
|
|
#Penup moving to fill in yellow rectangle
|
|
penup()
|
|
left(180)
|
|
forward(292)
|
|
right(90)
|
|
|
|
fillcolor('yellow')
|
|
begin_fill()
|
|
|
|
|
|
for side in range(2):
|
|
|
|
forward(126)
|
|
right(90)
|
|
forward(45)
|
|
right(90)
|
|
|
|
end_fill()
|
|
|
|
|
|
# Fill top left rectangle red
|
|
penup()
|
|
forward(388)
|
|
right(90)
|
|
|
|
fillcolor('red')
|
|
begin_fill()
|
|
|
|
for side in range(2):
|
|
forward(185)
|
|
right(90)
|
|
forward(166)
|
|
right(90)
|
|
|
|
end_fill()
|
|
|
|
# Go back to beginning, top left
|
|
penup()
|
|
pencolor('black')
|
|
setposition(-200, 200)
|
|
|
|
|
|
"""hide and show turtle to make sure lines are butting to each other"""
|
|
hideturtle()
|
|
|
|
done() |