The task is to display a series of vertical greyscale bars (contrast bars) with a sufficient number of bars to span the entire width of the display.

For the top quarter of the display, the left hand bar should be black, and we then incrementally step through six shades of grey until we have a white bar on the right hand side of the display. (This gives a total of 8 bars)

For the second quarter down, we start with white and step down through 14 shades of gray, getting darker until we have black on the right hand side of the display. (This gives a total of 16 bars).

Halfway down the display, we start with black, and produce 32 bars, ending in white, and for the last quarter, we start with white and step through 62 shades of grey, before finally arriving at black in the bottom right hand corner, producing a total of 64 bars for the bottom quarter.

' version 01-09-2017
'    compile with: fbc -s console
' or compile with: fbc -s gui
' hit any key to stop
 
Dim As UInteger d, blocks, blocksize, ps, col, h, w, x, y1, y2
 
ScreenInfo w, h
' create display size window, 8bit color (palette), no frame
ScreenRes w, h, 8,, 8
 
For x = 0 To 255        ' create grayscale palette for
    Palette x, x, x, x  ' the window we just opened
Next
 
h = h \ 4 : y2 = h -1
 
If w Mod 64 <> 0 Then w -= (w Mod 64)
blocks = 8 : blocksize = w \ 8
 
For ps = 1 To 4
    For x = 0 To blocks -1
        col = 255 * x \ (blocks -1)              ' from black to white
        If (ps And 1) = 0 Then col = 255 - col   ' from white to black
        Line (x * blocksize, y1) - (((x +1) * blocksize) -1, y2), col, bf
    Next
    y1 += h : y2 += h
    blocks *= 2 : blocksize \= 2
Next
 
' empty keyboard buffer
While Inkey <> "" : Wend
 
Sleep
End