-
Notifications
You must be signed in to change notification settings - Fork 0
/
PPE.py
146 lines (124 loc) · 3.39 KB
/
PPE.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# In[1]:
from turtle import Turtle
import turtle
AllLetters = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
NoDots = ["a","b","c","d","e","f","g","h","i"]
WithDots = ["j","k","l","m","n","o","p","q","r","w","y","z","x"]
Lefts = ["b","c","e","f","h","i","k","l","n","o","q","r"]
Rights = ["a","b","d","e","g","h","j","k","m","n","p","q"]
Bottoms = ["a","b","c","d","e","f","j","k","l","m","n","o"]
Tops = ["d","e","f","g","h","i","m","n","o","p","q","r"]
Diagonal = ["s","t","u","v"]
DiagonalDots = ["w","x","y","z"]
fontSize = 0.8
def InitialiseTurtle(t):
t.speed(0)
t.hideturtle()
t.pensize(3)
t.color('black')
def PenGoto(loc,t):
t.penup()
t.goto(loc)
t.pendown()
def Left(locx,locy,t):
PenGoto((locx,locy),t)
t.setheading(90)
t.forward(40*fontSize)
def Right(locx,locy,t):
PenGoto((locx+40*fontSize,locy),t)
t.setheading(90)
t.forward(40*fontSize)
def Bottom(locx,locy,t):
PenGoto((locx,locy),t)
t.setheading(0)
t.forward(40*fontSize)
def Top(locx,locy,t):
PenGoto((locx,locy+40*fontSize),t)
t.setheading(0)
t.forward(40*fontSize)
def LeftD(locx,locy,t):
PenGoto((locx,locy+20*fontSize),t)
t.setheading(90-63.43)
t.forward(44.72*fontSize)
PenGoto((locx,locy+20*fontSize),t)
t.setheading(-90+63.43)
t.forward(44.72*fontSize)
def RightD(locx,locy,t):
PenGoto((locx+40*fontSize,locy+20*fontSize),t)
t.setheading(90+63.43)
t.forward(44.72*fontSize)
PenGoto((locx+40*fontSize,locy+20*fontSize),t)
t.setheading(-90-63.43)
t.forward(44.72*fontSize)
def BottomD(locx,locy,t):
PenGoto((locx+20*fontSize,locy),t)
t.setheading(63.43)
t.forward(44.72*fontSize)
PenGoto((locx+20*fontSize,locy),t)
t.setheading(116.57)
t.forward(44.72*fontSize)
def TopD(locx,locy,t):
PenGoto((locx+20*fontSize,locy+40*fontSize),t)
t.setheading(-63.43)
t.forward(44.72*fontSize)
PenGoto((locx+20*fontSize,locy+40*fontSize),t)
t.setheading(180+63.43)
t.forward(44.72*fontSize)
def Square(mode,locx,locy):
if "left" in mode:
Left(locx,locy,draw)
if "right" in mode:
Right(locx,locy,draw)
if "bottom" in mode:
Bottom(locx,locy,draw)
if "top" in mode:
Top(locx,locy,draw)
if "deft" in mode:
LeftD(locx,locy,draw)
if "dot" in mode:
BottomD(locx,locy,draw)
if "dop" in mode:
TopD(locx,locy,draw)
if "dight" in mode:
RightD(locx,locy,draw)
def Circle(locx,locy,t):
temp = t.pensize()
PenGoto((locx+20*fontSize,locy+20*fontSize),draw)
draw.pensize(10*fontSize)
draw.forward(0.01)
draw.pensize(temp)
draw = Turtle()
InitialiseTurtle(draw)
x = -250
y = 200
PlainText = input("Enter the message to be displayed: ")
for i in PlainText:
try:
i = i.lower()
except:
None
mode = ""
if i in WithDots:
Circle(x,y,draw)
if i in Lefts:
mode+="left"
if i in Rights:
mode+="right"
if i in Bottoms:
mode+="bottom"
if i in Tops:
mode+="top"
if i in ["s","w"]:
mode+="dot"
if i in ["v","z"]:
mode+="dop"
if i in ["t","x"]:
mode+="dight"
if i in ["u","y"]:
mode+="deft"
Square(mode,x,y)
x += 45*fontSize
if x >= 250:
x = -250
y -= 45*fontSize
# In[]: