yclee126

No pen lift writing simulator

Nov 29th, 2021 (edited)
937
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.14 KB | None | 0 0
  1. # What will happen if you write without lifting your pen?
  2. # This code simulates that for each words.
  3. # I've added colors and offsets for more readability.
  4. # https://youtu.be/hqTX4vV5bI0
  5.  
  6. from turtle import *
  7. from time import sleep
  8.  
  9.  
  10. sh = setheading
  11.  
  12. def a():
  13.     sh(60)
  14.     forward(50)
  15.     sh(-60)
  16.     forward(50)
  17.     sh(0)
  18.     forward(20)
  19.  
  20. def b():
  21.     sh(-90)
  22.     forward(60)
  23.     sh(0)
  24.     circle(-15, 180)
  25.     sh(0)
  26.     circle(-15, 180)
  27.  
  28. def c():
  29.     sh(180)
  30.     circle(30, 180)
  31.  
  32. def d():
  33.     sh(-90)
  34.     forward(60)
  35.     sh(0)
  36.     circle(-30, 180)
  37.  
  38. def e():
  39.     sh(0)
  40.     forward(30)
  41.     sh(-90)
  42.     forward(60)
  43.     sh(0)
  44.     forward(30)
  45.     dot(5)
  46.     forward(30)
  47.  
  48. def f():
  49.     sh(0)
  50.     forward(30)
  51.     sh(-90)
  52.     forward(60)
  53.     sh(0)
  54.     forward(30)
  55.  
  56. def g():
  57.     sh(180)
  58.     circle(30, 180)
  59.     sh(90)
  60.     forward(30)
  61.     sh(0)
  62.     forward(15)
  63.  
  64. def h():
  65.     sh(-90)
  66.     forward(60)
  67.     sh(0)
  68.     forward(30)
  69.     sh(-90)
  70.     forward(60)
  71.  
  72. def i():
  73.     sh(0)
  74.     forward(30)
  75.     sh(-90)
  76.     forward(60)
  77.     sh(0)
  78.     forward(30)
  79.  
  80. def j():
  81.     sh(0)
  82.     forward(30)
  83.     sh(-90)
  84.     forward(30)
  85.     circle(-7, 180)
  86.  
  87. def k():
  88.     sh(-90)
  89.     forward(60)
  90.     sh(-120)
  91.     forward(30)
  92.     sh(-60)
  93.     forward(30)
  94.  
  95. def l():
  96.     sh(-90)
  97.     forward(60)
  98.     sh(0)
  99.     forward(30)
  100.  
  101. def m():
  102.     sh(-90)
  103.     forward(60)
  104.     sh(-60)
  105.     forward(30)
  106.     sh(60)
  107.     forward(30)
  108.     sh(-90)
  109.     forward(60)
  110.  
  111. def n():
  112.     sh(-90)
  113.     forward(60)
  114.     sh(-50)
  115.     forward(70)
  116.     sh(90)
  117.     forward(60)
  118.  
  119. def o():
  120.     sh(90)
  121.     circle(-20)
  122.  
  123. def p():
  124.     sh(-90)
  125.     forward(60)
  126.     sh(0)
  127.     circle(-15, 180)
  128.  
  129. def q():
  130.     sh(90)
  131.     circle(-20)
  132.     sh(-45)
  133.     forward(20)
  134.  
  135. def r():
  136.     sh(-90)
  137.     forward(60)
  138.     sh(0)
  139.     circle(-20, 180)
  140.     sh(-45)
  141.     forward(30)
  142.  
  143. def s():
  144.     sh(180)
  145.     circle(15, 180)
  146.     circle(-15, 180)
  147.  
  148. def t():
  149.     sh(0)
  150.     forward(30)
  151.     sh(-90)
  152.     forward(60)
  153.  
  154. def u():
  155.     sh(-90)
  156.     forward(30)
  157.     circle(15, 180)
  158.     forward(30)
  159.  
  160. def v():
  161.     sh(-70)
  162.     forward(50)
  163.     sh(70)
  164.     forward(50)
  165.  
  166. def w():
  167.     sh(-80)
  168.     forward(50)
  169.     sh(80)
  170.     forward(50)
  171.     sh(-80)
  172.     forward(50)
  173.     sh(80)
  174.     forward(50)
  175.  
  176. def x():
  177.     sh(-30-90)
  178.     forward(40)
  179.     sh(-(90-30))
  180.     forward(40)
  181.  
  182. def y():
  183.     sh(-45)
  184.     forward(20)
  185.     sh(-45-90)
  186.     forward(20)
  187.     sh(-90)
  188.     forward(30)
  189.  
  190. def z():
  191.     sh(0)
  192.     forward(30)
  193.     sh(-90-35)
  194.     forward(50)
  195.     sh(0)
  196.     forward(30)
  197.     dot(5)
  198.     forward(20)
  199.  
  200. def _():
  201.     sleep(1)
  202.     clear()
  203.     pu()
  204.     setpos(-320, 320)
  205.     pd()
  206.  
  207.  
  208. screensize(1000, 1000)
  209. speed(0)
  210. width(2)
  211. pu()
  212. setpos(-320, 320)
  213. pd()
  214.  
  215.  
  216. colors = ('red', 'blue')
  217. text = "    Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
  218.  
  219. for num, char in enumerate(text):
  220.     color(colors[num%2])
  221.    
  222.     char = char.lower()
  223.     try:
  224.         globals()[char]()
  225.     except:
  226.         _();
  227.    
  228.     color('lime')
  229.     sh(-45)
  230.     forward(5)
  231.    
  232.     sleep(0.1)
  233.  
  234. done()
  235. exit()
Add Comment
Please, Sign In to add comment