You will need to provide your own digits of Pi file. The one tested is massive and insane: One Billion Digits of Pi (1GB in size).
Several options available as variables can be changed as well as other possible changes:
Screen Resolution can be adjusted by editing xScreen and yScreen
Grid Size and Pixel Size can be adjusted with those variables.
There a re multiple Color options made available by uncommenting the appropriate one(s).
Changing tDigits=Space() to 1 or Grid Size will scroll the data right to left or bottom to top.
Press ESC to exit the program.
Make sure when ya download a Digits of Pi file to rename it as pidigits.txt.
Here are some links:
https://www.mathsisfun.com/numbers/pi-digits.html
https://pi2e.ch/blog/2017/03/10/pi-digits-download/
For the adventurous: https://archive.org/details/pi_dec_1t
Enjoy.
Known issues: Text is quite small and I am unsure how to fix this without using a font file.
Code: Select all
CLS
Sub ViewPi(xScreen as Integer, yScreen as Integer, _
ix as Integer, iy as Integer, _
GridSize as Integer, PixelSize as Integer, _
PiDigits as String)
Dim as Integer Pixels=GridSize*PixelSize
Dim as Integer xOffset=xScreen\2-(Pixels\2)
Dim as Integer yOffset=yScreen\2-(Pixels\2)
ScreenLock
Line (0, 0)-(xScreen-1, yScreen-1), RGB(0, 0, 0), bf
Line (xOffset-2, yOffset-2)-(Pixels+xOffset+2, Pixels+yOffset+2), 13, b
Color 3
Dim as Integer xPos=xScreen\8
Dim as Integer yPos=2*(yScreen\16-2)
If Len(PiDigits)>xPos then
Draw String (0, yScreen-32), Left(PiDigits, xPos)
Else
Draw String (xPos\2-4*Len(PiDigits), yScreen-32), PiDigits
EndIf
' Load Screen Data
For yPos as Integer=0 to GridSize-1
Dim as Integer yPixel=PixelSize*yPos+yOffset
For xPos as Integer=0 to GridSize-1
' Different Color Options
Dim as Integer tColor=0
Pixels=Val(Mid(PiDigits, (GridSize*yPos+xPos)+1, 1))
' Low Colors
tColor=Pixels
' tColor=9-Pixels
' Bright Colors
' tColor=Pixels+6
' tColor=15-Pixels
' Black and White
' If Pixels<5 then tColor=0 else tColor=7
' Greyscale
' If Pixels>0 and Pixels<4 then tColor=8 ' Low
' If Pixels>3 and Pixels<7 then tColor=7 ' Medium
' If Pixels>6 then tColor=15 ' Bright
Dim as Integer xPixel=PixelSize*xPos+xOffset
Line(xPixel, yPixel)-(xPixel+PixelSize-1, yPixel+PixelSize-1), _
tColor, bf
Next
Next
ScreenUnLock
Sleep 25
End Sub
Dim as Integer xScreen=1280
Dim as Integer yScreen=1024
ScreenRes xScreen, yScreen, 8
Width 25, 80
SetMouse 0, 0, 0
Dim as Integer GridSize=96
Dim as Integer PixelSize=8
' You need to provide your own Pi Digits File
Dim as Integer ff1=FreeFile
Open "./pi-billion.txt" for Binary as #ff1
Dim as String tDigits=Space(2)
Get #ff1, , tDigits ' Skip "3."
Dim as String PiDigits=Space(GridSize^2)
Get #ff1, , PiDigits
ViewPi xScreen, yScreen, 0, 0, GridSize, PixelSize, PiDigits
' Horizontal Scrolling: 1
' Vertical Scrolling: GridSize
tDigits=Space(GridSize)
While Not EOF(ff1)
Get #ff1, , tDigits
PiDigits=Right(PiDigits+tDigits, GridSize^2)
ViewPi xScreen, yScreen, 0, 0, GridSize, PixelSize, PiDigits
' Exit Program
If Inkey=Chr(27) then
Close #ff1 : End
End If
Wend
Close #ff1