From adb289680c36b17a2ac3e5aa2519a79a4aa63237 Mon Sep 17 00:00:00 2001 From: grace-xing6 Date: Thu, 19 Sep 2024 22:17:16 -0400 Subject: [PATCH] update a,b,c,i I was struggled with the error of test.py for a while, then I copied code to ChatGPT and asked it, I tried pip install superturtle to solve the problem under AI's help, which makes me relieved. Letter I: the easiest one Letter A: I started by using angle 80, then I figired that it's hard to do the math, so I changed it to 60 for easier caculation Letter B: I spent some time exploring how circle works and how initial direction might influence the circle draw, i also use speed() to fasten the process Letter C: two quater circle combined To make the pen get the initial position, I tried position() and home(), but they didn't work very well. Then I asked ChatGPT how to make it home to make proof.py work it gives me specific steps using penup and pendown etc to make it back, which is complicated. So I asked if there is a easier way to achieve this. Then it provides me with initial_position code, which concise the process. --- typeface.py | 72 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 5 deletions(-) diff --git a/typeface.py b/typeface.py index b966bef..56f70a4 100644 --- a/typeface.py +++ b/typeface.py @@ -1,5 +1,5 @@ # typeface.py -# By Chris Proctor and _________ +# By Chris Proctor and _____Grace____ # Contains one function for each letter in the English alphabet. # Each function should draw its letter at a scale of `unit`, and then @@ -13,14 +13,60 @@ from turtle import * from math import sqrt def draw_letter_a(unit): - pass + initial_position = pos() + initial_heading = heading() + left(60) + forward(8 * unit) + + right(120) + forward(8 * unit) + + backward(4 * unit) + right(120) + forward(4 * unit) + + penup() + setpos(initial_position) # Return to original position + setheading(initial_heading) # Return to original heading + pendown() def draw_letter_b(unit): - pass + initial_position = pos() + initial_heading = heading() + speed(0) + circle(2 * unit, 180) + left(180) + circle(2 * unit, 180) + left(90) + forward(8 * unit) + + penup() + setpos(initial_position) # Return to original position + setheading(initial_heading) # Return to original heading + pendown() def draw_letter_c(unit): - pass + initial_position = pos() + initial_heading = heading() + speed(0) + penup() + forward(4 * unit) + left(90) + forward(8 * unit) + pendown() + left(90) + circle(4 * unit, 180) + penup() + right(90) + forward(2 * unit) + pendown() + + penup() + setpos(initial_position) + setheading(initial_heading) + pendown() + def draw_letter_d(unit): pass @@ -37,7 +83,23 @@ def draw_letter_h(unit): pass def draw_letter_i(unit): - pass + initial_position = pos() + initial_heading = heading() + penup() + forward(4 * unit) + left(90) + pendown() + forward(5 * unit) + penup() + forward(1 * unit) + pendown() + forward(1 * unit) + + penup() + setpos(initial_position) + setheading(initial_heading) + pendown() + def draw_letter_j(unit): pass