From e67f4ad19cfe8428bd3c64b006c55aeb18a0569f Mon Sep 17 00:00:00 2001 From: tgaeta Date: Wed, 17 Sep 2025 14:22:50 -0400 Subject: [PATCH] Used Bezier curves to make fancy typeset. This assignment was fun to do. The implementation was way easier than I thought it would be. I know I'm supposed to make multiple commits, but I really only have 1 implementation. I got the constants by messing around in Desmos. --- .DS_Store | Bin 0 -> 6148 bytes typeface.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ab18bdb1b05edde16b34dc2dce93bb42b10b2c6c GIT binary patch literal 6148 zcmeHKJ5Iwu5S=wHjMAi_pg_VWKtwb&AQPDrq(uS}qXa3&E})?EHBxXD3MjY)m!P2M z&CV!zWlV`sG!xCf^?cU5&z2`cL~i_0jEIIrlt3AyZ45sM`&l~@sfC@6*I3R+lUY^P zok%nMR|fdm#dJV(x~2Q@`8~b1ePxyB(`7Y Point: + "Recursive definition of a Bezier curve" + assert(len(points) > 0) + if len(points) == 1: + return Point(points[0]) + return (1-t) * bezier(t, *points[0:-1]) + t * bezier(t, *points[1:]) + +def draw_bezier(unit, segments, *points: tuple[float, ...]): + "Draws bezier and returns turtle to initial position" + segments = int(unit * (segments / 40)) + origin = pos() + points = tuple(origin + unit * Point(x) for x in points) + + teleport(*points[0]) + for i in range(0, segments + 1): + bz = bezier(i / segments, *points) + goto(bz) + + teleport(*origin) + def draw_letter_a(unit): pass @@ -19,7 +53,11 @@ def draw_letter_b(unit): pass def draw_letter_c(unit): - pass + draw_bezier(unit, 160, + (7, 7), + (0.5, 11.88), + (0.5, -3.88), + (7, 1)) def draw_letter_d(unit): pass @@ -46,7 +84,11 @@ def draw_letter_k(unit): pass def draw_letter_l(unit): - pass + draw_bezier(unit, 100, + (1.46, 8), + (5.27, -6.66), + (-5.94, 4.27), + (7, 0)) def draw_letter_m(unit): pass @@ -73,10 +115,18 @@ def draw_letter_t(unit): pass def draw_letter_u(unit): - pass + draw_bezier(unit, 100, + (0.5, 8), + (0, -2.5), + (8, -2.5), + (7, 8)) def draw_letter_v(unit): - pass + draw_bezier(unit, 80, + (1, 8), + (4, -0.33), + (3.44, -4.33), + (7, 8)) def draw_letter_w(unit): pass