it keeps saying goals ran out of time and i dont think it made 1,000 fowers
# TEXT TO WRITE
text = "five wixen"
#self.setFlowerColor("red")
# options: "random" (default), "pink", "red", "blue", "purple", "yellow" or "white"
# settings
start = Vector(10, 90)
fontHeight = 20
fontWidth = fontHeight * 1/2
fontSpacing = fontWidth * 1/4
lineSpacing = fontHeight * 1/5
# vector fontset - INCOMPLETE
fontSet = {
# font format:
# "letter": [ (nextPosX, nextPosY, draw), ... ]
# note: 'draw' is optional, if it's not defined, the last value is used (= unchanged)
"A": [ (0, 0, 0), (1/2, 1, 1), (1, 0, 1), (5/6, 1/3, 0), (1/6, 1/3, 1) ],
"B": [ (0, 0, 0), (0, 1, 1), (3/4, 1, 1), (1, 5/6, 1), (1, 4/6, 1), (5/6, 1/2, 1), (0, 1/2, 1), (5/6, 1/2, 0), (1, 2/6, 1), (1, 1/6, 1), (5/6, 0, 1), (0, 0, 1) ],
# 'lazy' format example:
# "B": [(0, 0, 0), (0, 1, 1), (3/4, 1), (1, 5/6), (1, 4/6), (5/6, 1/2), (0, 1/2), (5/6, 1/2, 0), (1, 2/6, 1), (1, 1/6), (5/6, 0), (0, 0)],
# "C": [ (, , ) ],
# "D": [ (, , ) ],
"E": [ (1, 0, 0), (0, 0, 1), (0, 1, 1), (1, 1, 1), (0, 1/2, 0), (3/4, 1/2, 1) ],
"F": [ (0, 0, 0), (0, 1, 1), (1, 1, 1), (0, 1/2, 0), (3/4, 1/2, 1) ],
# "G": [ (, , ) ],
"H": [ (0, 0, 0), (0, 1, 1), (0, 1/2, 0), (1, 1/2, 1), (1, 1, 0), (1, 0, 1) ],
"I": [ (0, 0, 0), (0, 1, 1) ],
# "J": [ (, , ) ],
"K": [ (0, 0, 0), (0, 1, 1), (0, 1/2, 0), (1, 1, 1), (0, 1/2, 0), (1, 0, 1) ],
"L": [ (0, 1, 0), (0, 0, 1), (1, 0, 1) ],
"M": [ (0, 0, 0), (0, 1, 1), (1/2, 1/2, 1), (1, 1, 1), (1, 0, 1)],
"N": [ (0, 0, 0), (0, 1, 1), (1, 0, 1), (1, 1, 1) ],
# "O": [ (, , ) ],
# "P": [ (, , ) ],
# "Q": [ (, , ) ],
# "R": [ (, , ) ],
# "S": [ (, , ) ],
"T": [ (0, 1, 0), (1, 1, 1), (1/2, 1, 0), (1/2, 0, 1) ],
# "U": [ (, , ) ],
"V": [ (0, 1, 0), (1/2, 0, 1), (1, 1, 0) ],
"W": [ (0, 1, 0), (1/3, 0, 1), (2/3, 1/2, 1), (1, 0, 1), (4/3, 1, 1) ],
"X": [ (0, 0, 0), (1, 1, 1), (0, 1, 0), (1, 0, 1) ],
"Y": [ (0, 1, 0), (1/2, 1/2, 1), (1, 1, 1), (1/2, 1/2, 0), (1/2, 0, 1) ],
"Z": [ (0, 1, 0), (1, 1, 1), (0, 0, 1), (1, 0, 1) ],
" ": [ (1, 0, 0) ]
}
# make text uppercase
text = text.toUpperCase() # workaround for 'text.upper()'
self.toggleFlowers(False) # turn off flowers at start
# draw a letter
def writeLetter(char):
if char not in fontSet:
self.say("Letter " + char + " is not defined!")
return
corner = Vector(self.pos.x, baseLine)
maxWidth = 0
for point in fontSet[char]:
#self.say(point)
# # turn flowers on/off
# self.toggleFlowers(point[2])
if len(point) > 2:
if point[2]: # == 1
self.toggleFlowers(True)
else: # == 0
self.toggleFlowers(False)
# draw next segment
self.moveXY(corner.x + point[0] * fontWidth, corner.y + point[1] * fontHeight)
# proportional font support
if point[0] > maxWidth:
maxWidth = point[0]
self.toggleFlowers(False)
self.moveXY(corner.x + maxWidth * fontWidth + fontSpacing, corner.y)
#### main() ####
self.say("I will write: " + text)
self.moveXY(start.x, start.y) # move to starting position
baseLine = start.y
for i in range(len(text)):
self.say(text[i])
writeLetter(text[i])