; Best looking if running out of frames

Global BeamR.l
Global BeamG.l
Global BeamB.l

#Shift = 2
#Delay = 0
Global BeamCurrent.l

Procedure SplitCol(xLong1.l)
  Select xLong1
    Case 0 To 255
      BeamR = 255 - xLong1
      BeamG = xLong1
      BeamB = 0
    Case 256 To 510
      BeamR = 0
      BeamG = 511 - xLong1
      BeamB = xLong1 - 255
    Case 511 To 765
      BeamR = xLong1 - 510
      BeamG = 0
      BeamB = 766 - xLong1
    EndSelect
  EndProcedure

IncludeFile "LSDemo (PlasmaGrid).pb"

Procedure.l RM(Color.l, ColorFact.f)
  Color * ColorFact
  If Color < 0
    Color = 0
    ElseIf Color > $ff
    Color = $ff
    EndIf
  ProcedureReturn Color
  EndProcedure

Procedure.l ICol(Color.l, ColorFact.f)
  Color + (255 - Color) * ColorFact
  If Color < 0
    Color = 0
    ElseIf Color > $ff
    Color = $ff
    EndIf
  ProcedureReturn Color
  EndProcedure

Procedure.l RealFireOrBeamColor(xColor.f)
  Define.l xColorR

  If xColor > 1
    xColorR = $ffffff
    ElseIf xColor < 1/2
    xColor * 2
    xColorR = RM(BeamR, xColor) * $10000
    xColorR + RM(BeamG, xColor) * $100
    xColorR + RM(BeamB, xColor)
    
    Else
    xColor = (xColor - 1/2) * 2

    xColorR = ICol(BeamR, xColor) * $10000
    xColorR + ICol(BeamG, xColor) * $100
    xColorR + ICol(BeamB, xColor)
    EndIf

  ProcedureReturn xColorR
  EndProcedure
; IDE Options = PureBasic 5.20 LTS (Windows - x86)
; CursorPosition = 28
; FirstLine = 10
; Folding = -
; EnableAsm
; DisableDebugger
; AddResource = LSDemo (PlasmaGrid).rc