circular.py

Created by schraf

Created on October 03, 2023

881 Bytes

Alphabet Circular Glyphs | Youtube channel


from turtle import *

s = 10
w = 160 // s
speed(0)

def trait(x, y, a, b, r, u):
 penup()
 goto(x + a * u, y + b * u)
 setheading(r)
 pendown()
 fd(2 * u)    

def croix(x, y, u):
 trait(x, y, 0, -1, 90, u)
 trait(x, y, -1, 0, 0, u)

def arc(x, y, n, u):
 p = (n + n // 4) % 4
 xc = (0, 1, 0, -1)[p]
 yc = (1, 0, -1, 0)[p]
 penup()
 goto(x + u * xc, y + u * yc)
 setheading(180 - 90 * p)
 pendown()
 circle(u, 90 * ( 1 + n // 4))

def car(x, y, c, u):
 m = c.upper()
 n = ord(m) - 65
 croix(x, y, u)
 if "A" <= m <= "Z":
  arc(x, y, n, u)
  if m >= "N": arc(x, y, n - 13, u // 2)

ph = "All human beings are bornfree and equal in dignityand rights  they are endowed with reason and conscience and should act towards one another in a spirit of brotherhood "

for i,c in enumerate(ph):
 car(-160 + s + 2 * s * (i % w), 110 - s - 2 * s * (i // w), c, s)

hideturtle()