to aaa
;
; Since we already have an "addressable" graphics screen
; which can deal with text there is no reason it can't
; be used. Remember that's all a "DOS" window is or a CRT
; for that matter. With a mouse, addressable pixels and
; a turing machine you can do just about anything any
; other system can do.
;
; I replaced pr -> prx, type -> typex and added setcursor
; and clearlabel. With a little work you could make these
; routines more general purpose.
;
; Now that you have the text on the graphics screen it
; opens up all sorts of possibilities. Like a GIF animation,
; drawing a grid on it, using any Windows font, bold, italics
; size, color, other graphics. You could even allow
; the user to enter the matrix directly on the screen
; if your clever.
;
; People are always asking me for projects.
; How about building a simple spread sheet, each cell could
; be a logo expression. You have all the tools you need.
; This would be a very advanced project.
;
end
to display :a :b :c
make "n count :a
for [i 1 :n][
for [j 1 :n][
make "aa mditem se :i :j :a setcursor se :b+ :j*7 :i+ :c
typex form :aa 7 3 setcursor se 3 5
]
]
end
to go
cs
setlabelfont [[Courier New] -16 0 0 700 0 0 0 0 3 2 1 49]
init setcursor se 3 4 prx [original]
display :a 5 3 invert :a setcursor se 3 13
prx [inverse]
end
to init
make "a {{1 2 3 4 4 1 3 3}{4 5 6 7 2 3 3 1}{2 2 3 4 1 2 1 2}
{1 2 5 1 3 1 5 2}{3 0 4 4 6 1 4 1}{4 1 6 5 1 3 .7 3}
{3 2 5 1 3 3 9 1}{1 4 3 2 1 3 1 1}}
end
to invert :a
make "det 1
for [l 1 :n][
make "x mditem (se :l :l) :a make "det :det* :x
ifelse :x = 0 [prx [singular matrix] stop][mdsetitem (se :l :l) :a 1
for [j 1 :n 1][
make "k mditem (se :l :j) :a make "k :k/ :x
mdsetitem (se :l :j) :a :k]
for [i 1 :n][
ifelse :i=:l [typex " ][make "x mditem (se :i :l) :a
mdsetitem (se
:i :l) :a 0
for [j 1 :n][
make "aa mditem (se :i :j) :a make "bb mditem (se :l :j)
:a
make "bb :bb* :x make "bb :aa- :bb mdsetitem (se :i :j)
:a :bb
setcursor se 5+ :j*7 12+ :i prx form :bb 7 3 setcursor
se 3 5
;wait 1 ]
]
]
]
]
display :a 5 12 pr[]
end
to prx :text
; Since the given text varies in size we must erase the longest expected
clearlabel "XXXXXXXX
; True Type Font draws in turtle heading direction
setheading 90
label :text
pu
; Get the width and height of typical character in the current font
make "charwidth first labelsize "W
make "charheight last labelsize "W
; Zzzzzzzing (for those who remeber typewriters :-))
; Left Margin and down one character height
setx -:charwidth*32
sety ycor-:charheight
pd
end
to setcursor :xy
pu
; Get the width and height of a typical character in the current font
make "charwidth first labelsize "W
make "charheight last labelsize "W
; Now move turtle using character base units
; The 32 and the 12 are to get text reasonble centered on the graphics
screen
setxy ((first :xy)*:charwidth)-:charwidth*32 ((last
:xy)*:charheight)-:charheight*12
pd
end
to typex :text
; Since the given text varies in size we must erase the longest expected
clearlabel "XXXXXXXX
; True Type Font draws in turtle heading direction
setheading 90
label :text
pu
; Get the width of typical character in the current font
make "charwidth first labelsize "W
; Move turtle out the number of character widths labeled
setx ((count :text)*:charwidth)+xcor
pd
end
to clearlabel :text
; Get Dimensions of Text
make "x first labelsize :text
make "y last labelsize :text
pu
; Text works from upper left, bitblock works from lower left
sety ycor-:y
; Simulate Erase
setfloodcolor screencolor
; Erase it
bitblock :x :y
; Jump back
sety ycor+:y
pd
end
--
===============================================================
George Mills
email: mills@softronix.com
http://www.softronix.com
The www page contains some very powerful educational software.
Our single most important investment is our kids.
---------------------------------------------------------------
Please post messages to the Logo forum to logo-l@gsn.org. Mail
questions about the list administration to logofdn@gsn.org. To
unsubscribe send unsubscribe logo-l to majordomo@gsn.org.
Global SchoolNet Foundation -
Linking Kids Around the World!
Copyright GSN - All Rights Reserved
- Comments
& Questions
Visit GSN's
Global
Schoolhouse for more exciting learning resources!
Search our Site
-
Home