here2share

# t_color_alt_text.py -- and text_outline

Feb 12th, 2021 (edited)
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. # t_color_alt_text.py -- and text_outline
  2.  
  3. from turtle import Screen, Turtle
  4. from itertools import cycle
  5.  
  6. COLORS = cycle(["red","blue","yellow","green"])
  7.  
  8. STRING = "Hello World !!!!!"
  9.  
  10. FONT_SIZE = 60
  11. DELTA_SIZE = 4
  12. FONT = ("Ariel", FONT_SIZE, "italic")
  13.  
  14. tu = Turtle(visible=False)
  15. tu.speed('fastest')
  16.  
  17. font_width = 2
  18.  
  19. xy = [z-font_width-1 for z in range(1,(font_width+1)*2)]
  20. OUTLINE_FONT = [(x,y) for x in xy for y in xy]
  21.  
  22. screen = Screen()
  23. screen.tracer(0, 0)
  24. tu.penup()
  25. X, Y = -300, 100
  26. tu.goto(X, Y)
  27.  
  28. for letter in STRING+' ':
  29.     oldx = tu.xcor()
  30.     tu.write(letter, font=FONT)
  31.     tu.color('black')
  32.     if letter != ' ':
  33.         for x,y in OUTLINE_FONT:
  34.             tu.setposition(oldx+x, Y+y)
  35.             tu.write(letter, move=True, font=FONT)
  36.         tu.color(next(COLORS))
  37.     tu.setposition(oldx, Y)
  38.     tu.write(letter, move=True, font=FONT)
  39. screen.update()
Add Comment
Please, Sign In to add comment