aUCBLogo Demos and Tests / spelltest
to init_numpad_coors
numpad=array 9
repeat 9
[ numpad.repcount=
((list (mod (repcount-1) 3) int (repcount-1)/3)-1)*letter_scrunch*size/2
]
end
to make_path P
local [coors]
if (count P) == 1 [P=word P P]
coors=array count P
repeat count P
[ coors.repcount=numpad.(int P.repcount)
]
output coors
end
to make_letter L
if and list? L (count L) > 1
[ output se make_path first L make_letter bf L
]
output make_path first L
end
to init_letters size
letter_scrunch = list 7/8 1
letter_width = int 12/8*size*(first letter_scrunch)
letter_height = int 14/8*size*(first bf letter_scrunch)
letter_size = list letter_width letter_height
init_numpad_coors
letters=
[ [A 1486463]
[B 5317954]
[C 3179]
[D 178621]
[E 9746413]
[F 145479]
[G 563179]
[H 1745693]
[I 1325879]
[J 79324]
[K 1745953]
[L 713]
[M 17593]
[N 1739]
[O 17931]
[P 17964]
[Q 531793]
[R 1795453]
[S 974631]
[T 7982]
[U 7139]
[V 729]
[W 71539]
[X 19573]
[Y 75952]
[Z 7913]
[1 482]
[2 796413]
[3 7965631]
[4 2846]
[5 974631]
[6 971364]
[7 791]
[8 47964136]
[9 647931]
[0 179319]
[+ 46528]
[- 46]
[* 285375645915]
[/ 19]
[. 12]
[, 15]
[` 75]
[_ 13]
[= 13 46]
[< 349]
[> 167]
[% 19 32 78]
[: 12 45]
[" 57 68]
[? 78965 21]
[! 58 21]
[; 12 55]
[[ 3289]
[] 7821]
[( 359]
[) 157]
[{ 95453]
[} 75651]
[\ 73]
]
foreach letters
[ make (word "letter_ first ?) make_letter bf ?
]
advance_letter_proc = [advance_letter_horizontal]
advance_letter_circular_angle=10
newline_after_spell=false
newline_clean=false
setPenSize int letter_size*2/15
end
to advance_letter_horizontal
rt 90 fd letter_width lt 90
end
to advance_letter_vertical
rt 180 fd letter_width lt 180
end
to advance_letter_circular
local [a]
a=advance_letter_circular_angle
rt 90-a fd letter_width lt 90+a
end
to hLetter
advance_letter_proc = [advance_letter_horizontal]
end
to vLetter
advance_letter_proc = [advance_letter_vertical]
end
to cLetter
advance_letter_proc = [advance_letter_circular]
end
to clean_line
fillRect
(list -letter_width/2 letter_height/2*1.1)
(list 800-letter_width/2 -letter_height/2*1.1)
updateGraph
end
to edge
setXY -400+letter_width/2 300-letter_height/2
setHeading 0
end
to newline
setX -400+letter_width
setHeading 0
catch "error [setY ycor-letter_height]
setHeading 0
if not empty? error [edge]
if newline_clean [clean_line]
end
to advance_letter
catch "error advance_letter_proc
if not empty? error [newline]
end
to write_letter L
local [m lettername coors c]
if L=="\ [repeat 2 [advance_letter] stop]
if L=="\ [stop]
if L=="
[newline stop]
; m=Matrix
pushMatrix
setTurtleMatrix
letter = word "letter_ L
ifelse name? letter
[ coors = thing word "letter_ L
][ coors = letter_? (pr [unknown letter] L)
]
pd
line :coors pc
pu
popMatrix
; setMatrix m
end
to spell letter
foreach letter
[ ifelse char? ?
[ write_letter ?
]
[ spell ?
]
advance_letter
]
if newline_after_spell [newline]
end
to myhome
setPos p0
setHeading h0
end
to spelltest
; cs
;perspective
local [p0 h0]
p0=pos
h0=heading
pu WindowMode setFloodColor hsb 0 0 1
init_letters 40
spell "hello
myhome bk 100 rt advance_letter_circular_angle*4
cLetter
spell "world
myhome rt advance_letter_circular_angle*8 bk 200
advance_letter_circular_angle=5
setPrintPrecision 15
spell pi
hletter
init_letters 12
myhome lt 120 fd 400 rt 65
spell [Variables won`t, Constants aren`t.]
end
to spelltest2 ;one more example
local [hue]
ht
forever
[ setpc hsb 5*repcount 1 1
spelltest
updateGraph
if key? [stop]
]
end
to spelltext ;and a third example
ht edge
fence seth 0
setpc bitnot sc
setfc hsb 0 0 1
newline_after_spell=true
newline_clean=true
foreach procedures [spell fulltext ?]
end