Quick Grayscale Tutorial3 level gray:Three level grayscale is utilized by using the command DispGraph
r in place of the normal DispGraph command. Three level gray uses the backbuffer (L3) and the front buffer (L6). Everything on the back buffer will show as gray while everything on the front buffer will show as black. The front buffer is drawn over the back buffer, so if a pixel is "on" on both the front and back buffers, it will be shown as black.
You can change the common drawing operations Pt-On, Pt-Off, Pt-Change, Pxl-On, ClrDraw, Rect, Line, DrawInv, etc. to operate on the back buffer by adding the raidan
r at the end of the command. For example, Pt-On(X,Y,Pic1)
r will draw Pic1 to the backbuffer. If you then look at it with DispGraph, you will see it in gray.
Text, by default is drawn directly to the screen and not to the buffer. For this reason, it can appear as grayscale because it is being erased every time you call DispGraph
r, and then redrawn very quickly. To make it so that text is drawn to the buffer, put a Fix 5 at the beginning of the program (and a Fix 4 at the end). To draw text to the back buffer, you will have to Exch the back and front buffers, write to the front buffer, and switch back:
Exch(L3,L6,768): Text(X,Y,"Text") : Exch(L3,L6,768)
4 level grayWith four level gray, the front buffer becomes somewhat transparent. Use the following table to figure out the pixel colors:
Front:Back:Color
0 :1 :Light Gray
0 :0 :White
1 :0 :Dark Gray
1 :1 :Black
Buffer operations remain the same. To display in four level gray, use DispGraph
rrNote: In order for the grayscale to show up, you must put the DispGraph
r or DispGraph
rr in a loop. In monochrome, you can get away with this:
:Pt-On(X,Y,Pic1)
:DispGraph
:Repeat getKey
:End
But with grayscale, you'll have to write the code like this:
:Pt-On(X,Y,Pic1)
:Repeat getKey
:DispGraph[sup]r[/sup][sup]r[/sup]
:End
edit: 1000 posts