News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Parse and Plot Covid19 graphing

Started by kevin, April 01, 2020, 11:22:14 PM

Previous topic - Next topic

kevin

 Parse and Plot Covid19 graphing

    With the world in the grips coronavirus/covid19 and me being a numbers person, I of course wrote a program to plot out the data in Australia

PlayBASIC Code: [Select]
; PROJECT : Parse and Plot Covid19 graph
; AUTHOR : Kevin Picone
; CREATED : 24/03/2020
; EDITED : 30/03/2020
; ---------------------------------------------------------------------
// adjust screen positioning
positionscreen getscreenXpos(),10

// Load agency Fb font as the default
loadfont "agency fb",1,48
loadfont "agency fb",2,32


File$="C:\Users\Kevin\Desktop\Corona - States\Stats.txt"


ParseStats(File$)

setfps 10

Frames=0
do
cls $223355

RenderInFections()

Frames++
sync
loop Spacekey()<>0 or Frames>600

end


Type tViewPort
ScaleX#,ScaleY#
EndType
Dim ViewPort as tViewPort


Function Init_Default_Viewport()
Dim ViewPort as tViewPort
ViewPort = new tViewPort
Viewport.scalex = 1
Viewport.scaley = 1
EndFunction


Type tRect
x1,y1,x2,y2
EndType


Type tInFection
date$
Count
DeltaCount
rect as tRect
ScreenX,ScreenY
EndType

Dim infections(1000) as tInfection

Function RenderInfections()

if getArrayStatus(ViewPort())=false then Init_Default_Viewport()


Count=FindHighestInfectionIndex()


Dim Palette(2)

Palette(0) = $40ff55
Palette(1) = Rgbfade(Palette(0),50)

Xpos=0
Ypos=GetScreenheight()-2


ScaleX# =GetScreenWidth()/float(Count+1)


HighestInfection = FindHighestInfection()

ScaleY# =(Ypos-20)/float(HighestInfection)

print "Infections #"+str$(Count)+" - Highest #"+str$(HighestInfection)

for lp=1 to Count

Xpos = (lp*ScaleX#)
Xpos2 =((lp+1)*ScaleX#)

InfectionDate$ =Infections(lp).Date$
InfectionCount =Infections(lp).Count

Ypos2=Ypos - (InfectionCount * ScaleY#)
boxc xpos,ypos,xpos2,ypos2,true,Palette(PaletteIndex)

Infections(lp).Rect.x1 = Xpos
Infections(lp).Rect.y1 = Ypos2
Infections(lp).Rect.x2 = Xpos2
Infections(lp).Rect.y2 = Ypos

PaletteIndex =1 - PaletteIndex
next


// ---------------------------------------------------------------
// Mouse over column
// ---------------------------------------------------------------

mx=mousex()
my=mousey()

lastx=Infections(1).Rect.x2
lasty=Infections(1).Rect.y2

for lp=1 to count
xpos =Infections(lp).Rect.x1
ypos =Infections(lp).Rect.y1
xpos2 =Infections(lp).Rect.x2
ypos2 =Infections(lp).Rect.y2

x=(xpos+xpos2)/2
y=(ypos)
inkmode 1+32
circlec x,y,5,true,$111111
line lastx,lasty,x,y
inkmode 1

Infections(lp).ScreenX=X
Infections(lp).ScreenY=Y

lastx=x
lasty=y
next




for lp=2 to count-2

lastLP=lp-1

x1=Infections(Lastlp).ScreenX
y1=Infections(Lastlp).ScreenY

Login required to view complete source code



  Video Showing the program running