generated from mwc/project_drawing
I was able to draw a pattern of squares with a cool design.
Somewhere I got stuck was when I had to figure out how to turn around to draw more squares. A strategy I used to get un-stuck was trial and error until I got the turtle to rotate in the right way. Something I want to learn more about is how to do the same pattern but with different shapes. I challenged myself in completing this project in under 100 lines of code, and I succeeded with the help of defining and iterations.
This commit is contained in:
@@ -12,10 +12,10 @@ which allows basic formatting.
|
|||||||
(Describe your goal for this project. If you want to link to an
|
(Describe your goal for this project. If you want to link to an
|
||||||
image, move the image to this directory, and then use the following syntax:
|
image, move the image to this directory, and then use the following syntax:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
## Planning
|
## Planning
|
||||||
|
|
||||||
(Include your planning here, including your project milestone.)
|
Halfway finished for me would be being able to create one of the squares in the pattern.
|
||||||
|
|||||||
81
drawing.py
81
drawing.py
@@ -1,7 +1,86 @@
|
|||||||
# drawing.py
|
# drawing.py
|
||||||
# ----------
|
# ----------
|
||||||
# By ____(you)___________
|
# By Kayden
|
||||||
#
|
#
|
||||||
# (Briefly describe what this program does.)
|
# (Briefly describe what this program does.)
|
||||||
|
|
||||||
from turtle import *
|
from turtle import *
|
||||||
|
from math import sqrt
|
||||||
|
|
||||||
|
def fly(distance):
|
||||||
|
"The turtle moves without drawing for a specified distance."
|
||||||
|
penup()
|
||||||
|
forward(distance)
|
||||||
|
pendown()
|
||||||
|
|
||||||
|
def square(size):
|
||||||
|
"This function defines the drawing of a square with an iteration."
|
||||||
|
for i in range(4):
|
||||||
|
forward(size)
|
||||||
|
right(90)
|
||||||
|
|
||||||
|
def pattern():
|
||||||
|
"The function draws a square in a square 3 times."
|
||||||
|
left(45)
|
||||||
|
square(50)
|
||||||
|
fly(5)
|
||||||
|
right(90)
|
||||||
|
fly(5)
|
||||||
|
left(90)
|
||||||
|
square(40)
|
||||||
|
fly(5)
|
||||||
|
right(90)
|
||||||
|
fly(5)
|
||||||
|
left(90)
|
||||||
|
square(30)
|
||||||
|
|
||||||
|
def rotateright():
|
||||||
|
"The turtle draws the pattern then moves and rotates right."
|
||||||
|
pattern()
|
||||||
|
left(135)
|
||||||
|
fly(15)
|
||||||
|
right(90)
|
||||||
|
fly(70)
|
||||||
|
right(90)
|
||||||
|
|
||||||
|
def rotateleft():
|
||||||
|
"The turtle draws the pattern then moves and rotates left."
|
||||||
|
pattern()
|
||||||
|
right(45)
|
||||||
|
fly(55)
|
||||||
|
left(90)
|
||||||
|
fly(70)
|
||||||
|
left(90)
|
||||||
|
fly(71)
|
||||||
|
left(180)
|
||||||
|
|
||||||
|
def drawright():
|
||||||
|
"The turtle draws squares to the right."
|
||||||
|
for i in range(5):
|
||||||
|
pattern()
|
||||||
|
left(135)
|
||||||
|
fly(85)
|
||||||
|
right(180)
|
||||||
|
|
||||||
|
def drawleft():
|
||||||
|
"The turtle draws squares to the left."
|
||||||
|
for i in range(5):
|
||||||
|
pattern()
|
||||||
|
right(45)
|
||||||
|
fly(57)
|
||||||
|
|
||||||
|
def draw():
|
||||||
|
drawright()
|
||||||
|
rotateright()
|
||||||
|
drawleft()
|
||||||
|
rotateleft()
|
||||||
|
|
||||||
|
"The turtle starts at a specific point and facing a specific direction."
|
||||||
|
penup()
|
||||||
|
goto(-180,180)
|
||||||
|
pendown()
|
||||||
|
left(180)
|
||||||
|
for i in range(3):
|
||||||
|
draw()
|
||||||
|
|
||||||
|
input()
|
||||||
BIN
image.jpeg
Normal file
BIN
image.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 822 KiB |
Reference in New Issue
Block a user