EXAMPLE: RASTER GRAPHICS
The
following example program prints raster graphics in the
shape
of
a small arrow.
The
illustration
of
1 's
and
O's
shows how
each
dot
is
placed
to
form the arrow. A
"1"
causes the printer
to
print
a dot and a zero causes a space. (Actually, each
dot
in
the
representation
is
equivalent
to
sixteen dots because the resolution
is
set
to
75
dots/inch.)
In BASIC, data must be sent
to
the
printer
in decimal numbers (in
the
form
CHR$(decimal number». Therefore, each group
of
eight l's
or
O's
(each byte) must be converted
to
a decimal number
(see ASCII table in Appendix
B).
The
following illustration shows
the
binary
(l's
and
O's)
representation
of
the
arrow
and illustrates
how
the first line
of
binary data
is
converted
to
decimal so that
BASIC can interpret the data. NOTE:
The
example has been
tested using MicroSoft BASIC, version D3.0 or A3.0 on the IBM
Pc.
Other versions or releases
mayor
may not support some of
the
BASIC commands (such as
WIDTH
"LPT1:",255).
(LINE
1)
DECIMAL
CONVERSION
BINARY
REPRESENTATION
byte
1
byte
2
byte
3
byte
4
0
liB
0
2
'00000000 '00000000
'10000000' '00000000'
:::=====~~==::::
ooooooe
byte
1
byte
2
byte
3
byte
4
00000oo
0000000
,
, ,
,
000000.
000000.
0000000
00000.0
CHR$(O); CHR$(O); CHR$(12B);
CHR$(O);
1.000000
1.1.00000
1.110000
1111000
U11100
1UU1.
1111111
1111111
1111.110
+
11.11.100
PRINTED
11.11000
RASTER
11.10000
11.00000
GRAPHICS
1000000
0000000
0000000
0000000
0000000
000000.
000000.
0000000
00001
0000000
:
::::~:::::t.:::::t000OOO.
2-40