diff --git a/__pycache__/typeface.cpython-311.pyc b/__pycache__/typeface.cpython-311.pyc index 93becf4..ca48068 100644 Binary files a/__pycache__/typeface.cpython-311.pyc and b/__pycache__/typeface.cpython-311.pyc differ diff --git a/animated_square.py b/animated_square.py index eeeef72..9fec91b 100644 --- a/animated_square.py +++ b/animated_square.py @@ -1,21 +1,41 @@ from superturtle.animation import animate from turtle import * from turtle import forward, right +from typeface import ( + draw_letter_p, + draw_letter_i, + draw_letter_e, + draw_letter_t, +) +pensize(3) begin_fill() def square(side_length): + pensize(None) fillcolor('blue') begin_fill() for side in range(4): forward(side_length) right(90) + end_fill() +for i in range(3): + #animates 3 times and then stops + for frame in animate(40): + size = frame.interpolate(50, 100, mirror=True) + square(size) + penup() + back(90) + pendown() + draw_letter_p(size/4) + forward(63) + draw_letter_i(size/4) + forward(22) + draw_letter_e(size/4) + forward(75) + draw_letter_t(size/4) +done() -for frame in animate(40, loop=True): - size = frame.interpolate(50, 100, mirror=True) - square(size) - - end_fill() \ No newline at end of file diff --git a/drawing.py b/drawing.py index 523e47e..8dce27e 100644 --- a/drawing.py +++ b/drawing.py @@ -8,10 +8,27 @@ across to create one fill square and two fill rectangles in a Piet Mondrian abst a few shapes (squares and rectangles) will be drawn and filled with primary colors, red, blue, yellow. """ +from superturtle.animation import animate +from turtle import forward, right from turtle import * +from superturtle.movement import no_delay +from typeface import ( + draw_letter_p, + draw_letter_i, + draw_letter_e, + draw_letter_t, + draw_letter_m, + draw_letter_o, + draw_letter_n, + draw_letter_d, + draw_letter_r, + draw_letter_i, + draw_letter_a, + draw_letter_n, +) screensize(500, 500) -speed(9) +speed(10) # Positioning pen in upper left of screen penup() @@ -23,7 +40,6 @@ pendown() pencolor("black") pensize(2) - # Drawing a square def square(side_length): for side in range(4): @@ -175,6 +191,7 @@ for side in range(2): right(90) end_fill() +fillcolor('white') # Go back to beginning, top left penup() @@ -182,7 +199,67 @@ pencolor('black') setposition(-200, 200) -"""hide and show turtle to make sure lines are butting to each other""" +#Draw letters PIET MONDRIAN, ARTIST +left(90) +forward(40) +right(90) + +with no_delay(): + penup() + back(60) + pendown() + draw_letter_p(25/4) + forward (33) + draw_letter_i(25/4) + penup() + forward (15) + pendown() + draw_letter_e(25/4) + penup() + forward (40) + pendown() + draw_letter_t(25/4) + penup() + forward (40) + pendown() + draw_letter_m(25/4) + penup() + forward (46) + pendown() + draw_letter_o(25/4) + penup() + forward (46) + pendown() + draw_letter_n(25/4) + penup() + forward (46) + pendown() + draw_letter_d(25/4) + penup() + forward (46) + pendown() + draw_letter_r(25/4) + penup() + forward (34) + pendown() + draw_letter_i(25/4) + penup() + forward (13) + pendown() + draw_letter_a(25/4) + penup() + forward (38) + pendown() + draw_letter_n(25/4) + +# Go back to beginning, top left of square box +penup() +pencolor('black') +setposition(-200, 200) + + +#hide and show turtle to make sure lines are butting to each other + hideturtle() done() \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index b03b36d..db2e785 100644 --- a/poetry.lock +++ b/poetry.lock @@ -159,13 +159,13 @@ files = [ [[package]] name = "furo" -version = "2023.8.17" +version = "2023.8.19" description = "A clean customisable Sphinx documentation theme." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "furo-2023.8.17-py3-none-any.whl", hash = "sha256:baed406fc8f75a585caa330756b6841e6a1d4c844a3a355387e01ba9d1a4c6ee"}, - {file = "furo-2023.8.17.tar.gz", hash = "sha256:56664be7290d1457a49d6c2c98cbf96537b9ee1cf05d28e05a5178e76abe5c55"}, + {file = "furo-2023.8.19-py3-none-any.whl", hash = "sha256:12f99f87a1873b6746228cfde18f77244e6c1ffb85d7fed95e638aae70d80590"}, + {file = "furo-2023.8.19.tar.gz", hash = "sha256:e671ee638ab3f1b472f4033b0167f502ab407830e0db0f843b1c1028119c9cd1"}, ] [package.dependencies] @@ -479,13 +479,13 @@ test = ["pytest"] [[package]] name = "sphinxcontrib-serializinghtml" -version = "1.1.8" +version = "1.1.9" description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)" optional = false python-versions = ">=3.9" files = [ - {file = "sphinxcontrib_serializinghtml-1.1.8-py3-none-any.whl", hash = "sha256:27849e7227277333d3d32f17c138ee148a51fa01f888a41cd6d4e73bcabe2d06"}, - {file = "sphinxcontrib_serializinghtml-1.1.8.tar.gz", hash = "sha256:aaf3026335146e688fd209b72320314b1b278320cf232e3cda198f873838511a"}, + {file = "sphinxcontrib_serializinghtml-1.1.9-py3-none-any.whl", hash = "sha256:9b36e503703ff04f20e9675771df105e58aa029cfcbc23b8ed716019b7416ae1"}, + {file = "sphinxcontrib_serializinghtml-1.1.9.tar.gz", hash = "sha256:0c64ff898339e1fac29abd2bf5f11078f3ec413cfe9c046d3120d7ca65530b54"}, ] [package.dependencies] diff --git a/typeface.py b/typeface.py new file mode 100644 index 0000000..d0c32df --- /dev/null +++ b/typeface.py @@ -0,0 +1,497 @@ + +# typeface.py +# By Chris Proctor and _________ + +# Contains one function for each letter in the English alphabet. +# Each function should draw its letter at a scale of `unit`, and then +# return back to the same position and heading where it started. + +# Note: The `sqrt` function from math may be helpful--if you want to +# move the turtle along the diagonal of a square with side length x, +# the turtle should move a distance of sqrt(x) + +from turtle import * +from math import sqrt + +pensize(5) + +def draw_letter_a(unit): + + penup() + forward(unit*1) + pendown() + + # 1st & 2nd stem sections of letter + forward(unit*2) + left(90) + forward(unit*3) + right(90) + forward(unit*2) + right(90) + forward(unit*3) + left(90) + forward(unit*2) + left(90) + forward(unit*6) + + # 45 degree top section of letter + left(45) + forward(unit * 2 * sqrt(2)) + left(45) + forward(unit*2) + left(45) + forward(unit * 2 * sqrt(2)) + left(45) + + #remander of left stem section of letter + forward(unit*6) + left(90) + + #interior cross bar section + penup() + left(90) + forward(unit*4) + right(90) + forward(unit*2) + pendown() + forward(unit*2) + left(90) + forward(unit*1) + left(45) + forward(unit * 1 * sqrt(2)) + left(90) + forward(unit * 1 * sqrt(2)) + left(45) + forward(unit*1) + + #penup moving back to initial position + penup() + right(90) + forward(unit*2) + left(90) + forward(unit*4) + + # Start position + left(90) + +def draw_letter_b(unit): + pass + +def draw_letter_c(unit): + pass + +def draw_letter_d(unit): + penup() + forward(unit*1) + + "Draw base and right side of D" + pendown() + forward(unit*4) + left(45) + forward(unit * 2 * sqrt(2)) + left(45) + forward(unit*4) + left(45) + forward(unit * 2 * sqrt(2)) + + "Top and left side of D" + left(45) + forward(unit*4) + left(90) + forward(unit*8) + + "Inner section of D" + penup() + left(180) + forward(unit*2) + right(90) + forward(unit*2) + pendown() + forward(unit*1) + left(45) + forward(unit * 1 * sqrt(2)) + left(45) + forward(unit*2) + left(45) + forward(unit * 1 * sqrt(2)) + left(45) + forward(unit*1) + left(90) + forward(unit*4) + + "Back to beginning" + penup() + right(90) + forward(unit*3) + left(90) + forward(unit*2) + left(90) + +def draw_letter_e(unit): + + penup() + forward(unit*1) + pendown() + + #Base leg section + forward(unit*6) + left(90) + forward(unit*2) + left(90) + forward(unit*4) + right(90) + + # middle section + forward(unit*1) + right(90) + forward(unit*4) + left(90) + forward(unit*2) + left(90) + forward(unit*4) + right(90) + + # arm (top) section + forward(unit*1) + right(90) + forward(unit*4) + left(90) + forward(unit*2) + left(90) + forward(unit*6) + + # completing stem of letter + left(90) + forward(unit*8) + + # Start position + left(90) + + +def draw_letter_f(unit): + pass + +def draw_letter_g(unit): + pass + +def draw_letter_h(unit): + pass + +def draw_letter_i(unit): + + # penup to move into position to draw + penup() + forward(unit*3) + pendown() + + #Stem of letter "I" + forward(unit*2) + left(90) + forward(unit*8) + left(90) + forward(unit*2) + left(90) + forward(unit*8) + + #Start position + left(90) + +def draw_letter_j(unit): + pass + +def draw_letter_k(unit): + pass + +def draw_letter_l(unit): + pass + +def draw_letter_m(unit): + penup() + forward(unit*1) + + "beginning stem section and bottom section of N" + pendown() + forward(unit*2) + left(90) + forward(unit*4) + right(135) + forward(unit * 1 * sqrt(2)) + left(90) + forward(unit * 1 * sqrt(2)) + right(45) + right(90) + forward(unit*4) + left(90) + forward(unit*2) + + "Right stem section and top of N" + left(90) + forward(unit*8) + left(90) + forward(unit*2) + left(45) + forward(unit * 1 * sqrt(2)) + right(90) + forward(unit * 1 * sqrt(2)) + left(45) + forward(unit*2) + + "Left stem of N" + left(90) + forward(unit*8) + + "Back to beginning" + penup() + right(90) + forward(unit*1) + right(180) + + +def draw_letter_n(unit): + + penup() + forward(unit*1) + + "1st stem section and angle of N" + pendown() + forward(unit*2) + left(90) + forward(unit*3) + right(135) + forward(unit * 3 * sqrt(2)) + left(45) + forward(unit*1) + + "Right and top of N" + left(90) + forward(unit*8) + left(90) + forward(unit*2) + left(90) + forward(unit*3) + right(135) + forward(unit * 3 * sqrt(2)) + left(45) + forward(unit*1) + + "Left side of stem N" + left(90) + forward(unit*8) + + "Back to beginning" + penup() + right(90) + forward(unit*1) + right(180) + +def draw_letter_o(unit): + penup() + forward(unit*3) + + "Draw base of O" + pendown() + forward(unit*2) + + "Right side and top of O" + left(45) + forward(unit * 2 * sqrt(2)) + left(45) + forward(unit*4) + left(45) + forward(unit * 2 * sqrt(2)) + left(45) + forward(unit*2) + + "Left side of O" + left(45) + forward(unit * 2 * sqrt(2)) + left(45) + forward(unit*4) + left(45) + forward(unit * 2 * sqrt(2)) + + "Inner section of O" + penup() + left(135) + forward(unit*3) + right(90) + pendown() + forward(unit*2) + left(90) + forward(unit*2) + left(90) + forward(unit*2) + left(90) + forward(unit*2) + + "Back to start" + penup() + right(90) + forward(unit*3) + left(90) + forward(unit*3) + left(90) + +def draw_letter_p(unit): + penup() + forward(unit*1) + pendown() + + "Draw bottom and right side of stem" + forward(unit*2) + left(90) + forward(unit*2) + + "Right and top section of P" + right(90) + forward(unit*2) + left(45) + forward(unit * 2 * sqrt(2)) + left(45) + forward(unit*2) + left(45) + forward(unit * 2 * sqrt(2)) + left(45) + forward(unit*4) + + "Left section of stem to bottom" + left(90) + forward(unit*8) + + "Inner section of P" + penup() + left(180) + forward(unit*4) + right(90) + + forward(unit*2) + pendown() + forward(unit*2) + left(90) + forward(unit*2) + left(90) + forward(unit*2) + left(90) + forward(unit*2) + + "Pen Back to the beginning" + penup() + right(90) + forward(unit*3) + left(90) + forward(unit*4) + left(90) + +def draw_letter_q(unit): + pass + +def draw_letter_r(unit): + penup() + forward(unit*1) + pendown() + + "1st & 2nd stem sections of R" + forward(unit*2) + left(90) + forward(unit*3) + right(90) + forward(unit*2) + right(90) + forward(unit*3) + left(90) + forward(unit*2) + left(90) + forward(unit*3) + + "Angled right sections of R" + left(45) + forward(unit * 1 * sqrt(2)) + right(90) + forward(unit * 1 * sqrt(2)) + left(45) + forward(unit*2) + left(45) + forward(unit * 1 * sqrt(2)) + left(45) + + "Top and left stem of R" + forward(unit*5) + left(90) + forward(unit*8) + + "Inner section of R" + penup() + left(180) + forward(unit*4) + right(90) + forward(unit*2) + pendown() + forward(unit*2) + left(90) + forward(unit*2) + left(90) + forward(unit*2) + left(90) + forward(unit*2) + + "Back to beginning" + penup() + right(90) + forward(unit*3) + left(90) + forward(unit*4) + left(90) + +def draw_letter_s(unit): + pass + +def draw_letter_t(unit): + + penup() + forward(unit*3) + pendown() + + # right side of stem section + forward(unit*2) + left(90) + forward(unit*6) + + # Arm (top) section + right(90) + forward(unit*2) + left(90) + forward(unit*2) + left(90) + forward(unit*6) + left(90) + forward(unit*2) + left(90) + forward(unit*2) + + #left side of stem, moving down to start + right(90) + forward(unit*6) + + # Start position + left(90) + + + + +def draw_letter_u(unit): + pass + +def draw_letter_v(unit): + pass + +def draw_letter_w(unit): + pass + +def draw_letter_x(unit): + pass + +def draw_letter_y(unit): + pass + +def draw_letter_z(unit): + pass