13.6 Annotating Portable Bitmap images. 4tH 4tH Forth compiler
Tangazo
Tangazo
CHAPTER 13. SPECIAL LIBRARIES
W
ORD compass@ xhome xrotate xmove forward backward left right clear-screen xpenup n – n – n – n – n –
–
–
S
TACK EFFECT
– n
– n – xpendown –
C
OMMENT get turtle directional heading in degrees place turtle in center of image and set the heading to 0 degrees
Rotate turtle by n degrees, positive numbers are counter clockwise.
Move n pixels, can move forward
(+) or backwards (-)
Move n pixels forward
Move n pixels backwards
Turn left (rotate) by n degrees
Turn right (rtate) by n degrees
Clear to white background
Change color to white so that movent of turtle does not leave a trail on white background
Change color to blue; e.g., same as using the word blue.
209
13.6
Annotating Portable Bitmap images
9
To annotate the turtle graphic image from the last example, try the following: include lib/graphics.4th
include lib/gbanner.4th
s" box.ppm" get_image red horizontal text_up 5 25 s" boxes!" gbanner black vertical text_up 75 20 s" yea!" gbanner green vertical text_down 190 190 s" Hello there!" gbanner magenta horizontal text_down 190 150 s" Bye bye!" gbanner s" box2.ppm" save_image
The general syntax is just the screen position and the string with the key word being
”GBANNER”. To make it interesting, the orientation and direction of the text can easily be changed. Note the starting positions for the text in this example as the text may be written from right to left for some orientations.
The basic words are summarized as follows:
W
ORD
S
TACK EFFECT gbanner horizontal vertical textup textdown
–
– rx cy a n –
–
–
C
OMMENT print the string a n at position rx cy plot the text horizontally plot the text vertically change the text direction to upright change the text direction to upside down
9
Article written and contributed by David Johnson.
Pakua
Tangazo