RosettaCodeData/Task/Greyscale-bars-Display/FreeBASIC/greyscale-bars-display.basic

36 lines
867 B
Plaintext

' 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