-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLCARSeffects2.bas
10786 lines (9608 loc) · 470 KB
/
LCARSeffects2.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=StaticCode
Version=7.3
@EndOfDesignText@
'1:28 autodestruct is offline
'cache xy speeds for angles
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
'Universal buffer stuff
Dim CenterPlatformID As Int, CenterPlatform As Bitmap, WasInit As Boolean, UNIFILE As String
'Dim GIFloaded As Boolean, GIFFrames As Int, GIFwidth As Int, GIFheight As Int, GIFdrawn as boolean
'Matrix stuff
Dim LE_Turquoise255 As Int, LE_Turquoise000 As Int, LE_Blue As Int, LE_MaxLines As Int=30 , LE_Width As Int, LE_Height As Int ,LE_Changed As Boolean , LE_Border As Int=50 ,LE_IntBorder As Int
Dim LE_Initd As Boolean, LE_MinLength As Int, LE_MaxLength As Int , LE_MaxStatLines As Int=20 ,LE_StatLineHeight As Int=4,LE_MaxAngleLines As Int=10, LE_StringsPerLayer As Int, LE_MaxLayers As Int
Dim LE_StringLength As Int=20,LE_MaxStrings As Int = 5 , LE_GradAlpha As Boolean , LE_BloomThickness As Int=15, LE_Outside As Rect , LE_Inside As Rect ,LE_LastPath As Int
Dim LE_TextR As Int,LE_TextG As Int,LE_TextB As Int ,LE_BlueR As Int, LE_BlueG As Int, LE_BlueB As Int ,ColorsSet As Boolean
Type LE_Line(X As Int, Y As Int, Thickness As Int, Angle As Int, Speed As Int, Length As Int, GoingIn As Boolean,PathType As Int )
Type LE_String(X As Int, Y As Int, SpeedX As Int, SpeedY As Int, TextSize As Int, Alpha As Float, Text As String, Alphas As List, Frames As Int)
Dim LE_Lines(LE_MaxLines+LE_MaxAngleLines) As LE_Line , LE_StatLines(LE_MaxStatLines) As Int
Dim LE_Strings(LE_MaxStrings) As LE_String , aColors(17) As Int ,ColorsSet As Boolean , LockUniBMP As Boolean
'scan analysis stuff
Dim Layer(4) As Int , LayerColors(3) As Int ,LayerCount(3) As Int, Ovals(2) As TweenAlpha, IsAnalysisInit As Boolean
'starbase/starship clock stuff
Type Movement(MovementType As Int, Quantity As Int)'towards/away from center by distance, around center by degrees, orientation by degrees, infinite movement sync with seconds
Type Starship(Distance As Float, Angle As Int, Orientation As Int, Class As Int, Moving As Boolean, Registry As String, AI As List, Workbees As Int, DockingBay As Int, Door As Int, Origin As Point ,Cache As Rect,CacheNeedsInitializing As Boolean ,IsLeaving As Boolean,LastDrawn As Point )
Dim d45 As Int ,StarshipBMP As Bitmap ,Starships As List ,StarshipFont As Typeface ,StarshipsClean As Boolean ,OldDate As Int , StarshipScaleFactor As Int , DockingBays(8) As Boolean,Doors(4) As Boolean
Dim DoorsInUse As Int ,MovingShips As Int, DockedShips As Int ,DoorState(4)As Int ,oldseconds As Long=-1 ,StartAt As Float=1.2 ,OpenDoor As Int=5, DeleteShip As Int=6 ,OneTick As Double =1000/6,BorderThickness As Int =74
Dim Constitution As Int=1, Excelsior As Int, Reliant As Int=2, Workbee As Int=3 , RotateAroundCenter As Int=1, MoveTowardsCenter As Int ,RotateWithSeconds As Int=2 ,TurnStarship As Int= 3, CloseDoor As Int= 4
Dim InnerThickness As Int ,ChangeOrigin As Int=7,CurrRadius As Int, CurrentSecond As Int =-1, WorkbeeSpace As Int=10, MoveToAngle As Int=8, TurnToAngle As Int=9,WaitTicks As Int=10,WorkbeesRemaining As Int
Dim StopDrawing As Int=11 , DoPaths As Boolean , RemovingStarships As Boolean ,ColorWhite As Int, ColorGrey As Int ,HelpMode As Boolean,PortraitMode As Boolean,ForceRedraw As Boolean
StarshipBMP.Initialize(File.DirAssets,"starships.gif")
'graph stuff
Type Graph(ID As Int, Points As List, MaxPoints As Int, CurrentPoint As Int, IsClearing As Boolean,IsClean As Boolean, ExpandWhenFull As Int, BracketX As Int, MaxV As Double, MinV As Double)
Dim GraphList As List ,ResetToZero As Boolean, ZeroesInARow As Int
GraphList.Initialize
'PreCARS stuff
Dim PCARfont As Typeface, cachedTS(3) As Int , isFalse As Bitmap, IsTrue As Bitmap ,PCARlastupdate As Long, PCARdelay As Int = 200'GeneratePreCARSwave
Dim Images(10) As Bitmap , ENTTextSize As Int, ENTTextSize2 As Int, ENTScaleFactor As Float , ENTcanupdatewave As Boolean
isFalse.Initialize(File.DirAssets,"false.gif")
IsTrue.Initialize(File.DirAssets,"true.gif")
Images(0).Initialize(File.DirAssets,"t1.png")'top half of the top left corner
Images(1).Initialize(File.DirAssets,"t2.png")'bottom half of the top left corner
Images(2).Initialize(File.DirAssets,"tm.gif")'top middle bar
Images(3).Initialize(File.DirAssets,"tr.gif")'top right corner
Images(4).Initialize(File.DirAssets,"bl.gif")'bottom left corner
Images(5).Initialize(File.DirAssets,"bm.gif")'bottom bar
Images(6).Initialize(File.DirAssets,"br.gif")'bottom right corner
Images(7).Initialize(File.DirAssets,"ml.gif")'middle left bar
Images(8).Initialize(File.DirAssets,"mr.gif")'middle right bar
Images(9).Initialize(File.DirAssets,"t0.png")'no corner
'warp core status stuff
Dim WarpMode As Boolean=True, MaxStages As Int=16,theDIR As Boolean,PlasmaWidth As Int',laststage As Int 'true=animated, false=static
'real warp core stuff
Dim WarpScaleFactor As Double, WarpLowRes As Boolean ', WarpLastX As Int WarpLastX=-32760
'klingon stuff
Dim MaxKcycles As Int=32 , KlingonFont As Typeface
'Omegastuff
Dim CachedOmega As Rect ,TopTextWidth As Int, OmegaNeedsInit As Boolean
'Multispectral analysis
Type AxisPoint(Value As Int, Color As Int, Name As String, GraphID As Int, MinV As Int, MaxV As Int)
Dim AxisCount As Int=20, LastUpdate As Int=-1, MS As Int = DateTime.TicksPerSecond /2
Dim EnabledAxis As Int ,IsSetup As Boolean, IncDataPoints As Int,CurrCols As Int, RealMax As Int, Axis(AxisCount) As AxisPoint
'Dim Axis As List
'Moire stuff http://tosdisplaysproject.wordpress.com/bridge-station-displays/library_computer/
Dim MoireOffsets As Int =24
'Photonic Sonar stuff
Type SON_Point(Width As Int, CurrentOffset As Int, DesiredOffset As Int, Shade As Int, FullyOpaque As Boolean)
Type SON_Line( Layers(2, 4) As SON_Point, LastShade As Int)
Dim Sonar As List , SonarLines As Int=64, MaxSonarOffset As Int=10,SonarWidth As Int=40,SliverAura As Int=5, SonarTextSize As Int ,SonarTextHeight As Int
'Random number stuff
Type NumSec(Speed As Int, Y As Int)
Type NumLin(Lines As Int, RedAlert As Int, RandomizeFullList As Int )
Type NumCol(Digits As Int, Align As Int, ColorID As Int)
Type NumLis(Columns As List, Values As List, ColorID As Int, Age As Int, ID As Int, TotalWidth As Int)
Dim Numbers As List, LineList As List, ColumnList As List ,NumSection As Int ,LastSecond As Int,RandomizeFullList As Boolean ,ForcedNumber As Int=-1, LastAdditions As List, ScrollingMode As Boolean
'Periodic Table of Elements stuff
Type PToEShell(Electrons As Int, Angle As Int, Speed As Int)'ElectronShells
Type PToElement(X As Int,AtomicNumber As Int, Molecule As String, AtomicSymbol As String, AtomicWeight As Double, ElectronConfiguration As String, ElectronsPerShell As String,Color As Int)
Type PtoELine(Y As Int, Cols As List)
Dim Elements As List, SelectedElement As Point, PToECursor As Point, PToECursor2 As Point,PToECursor3 As Point , PToExtsize As Int, PToExtCache As Int, PToEScrolling As Boolean ,PToEColWidth As Int
Dim TheSelectedElement As Point , ElementData As PToElement,ElectronShells As List, LastUpdate As Int, ElementMode As Int,PTOESIZE As Int , PTOE_Longest As String
'PToEColWidth=135
'Adv. Drawing stuff
Dim mMatrix As ABMatrix, mPaint As ABPaint, mCamera As ABCamera,isAdvInit As Boolean
Dim AMBIENT_LIGHT As Int = 55 'Ambient light intensity
Dim DIFFUSE_LIGHT As Int = 200 'Diffuse light intensity
Dim SPECULAR_LIGHT As Float = 70 'Specular light intensity
Dim SHININESS As Float = 200 'Shininess constant
Dim MAX_INTENSITY As Int = 255 'The Max intensity of the light'0xFF
'Shuttlebay stuff (6 paths of 12 positions each)
Type Shuttle(Name As String,ColorID As Int, ShowIcon As Boolean , IsShuttle As Boolean, Index As Int, Status As String, Loc As String, inUse As Boolean, isOffship As Boolean)
Type ShuttleLine(ShuttleID As Int, Position As Int, Direction As Boolean, Age As Int)
Dim Shuttles As List ,ShuttleLines As List , MaxAge As Int =8,MaxPositions As Int=12,ShuttleTextHeight As Int ,ShuttleVehicleW As Int ,StatusW As Int, LocationW As Int
'colored square block stuff
Dim MaxSquareStages As Int =16, CurrentSquare As Int=-1
End Sub
Sub InitUniversalBMP(Width As Int, Height As Int, ElementType As Int) As Canvas
Dim BG As Canvas, NeedsInit As Boolean
WasInit=False
If Not(CenterPlatform.IsInitialized ) Or CenterPlatformID <> ElementType Then
NeedsInit=True
Else If CenterPlatform.Height<>Height Or CenterPlatform.Width <> Width Then
NeedsInit=True
End If
If NeedsInit Then
CenterPlatform.InitializeMutable(Width,Height)
CenterPlatformID = ElementType
WasInit=True
UNIFILE=""
End If
BG.Initialize2(CenterPlatform)
Return BG
End Sub
Sub FindDIR(Dir As String, Filename As String) As String
If Dir.Length=0 Then
If File.Exists(File.DirAssets, Filename) Then
Dir = File.DirAssets 'prioritize internal directory first
Else If File.Exists(LCAR.DirDefaultExternal, Filename) Then
Dir = LCAR.DirDefaultExternal
End If
End If
Return Dir
End Sub
'Sub DrawGIF(BG As Canvas, Frame As Int, X As Int, Y As Int, Width As Int, Height As Int) As Boolean
' GIFdrawn = False
' If Not(IsPaused(Main)) Then CallSub2(Main, "DrawGIF3", Array As Object(BG,Frame, LCARSeffects4.SetRect(X,Y,Width,Height)))
'' If Not(Async) Then
'' Log("WAITING")
'' Do Until GIFdrawn
'' DoEvents
'' Loop
'' End If
' 'LCAR.DrawText(BG,X,Y,"Frame: " & Frame & " " & Async, LCAR.LCAR_Orange, 0,False, 255,0)
'End Sub
'Sub LoadUniversalGIF(Dir As String, Filename As String, ElementType As Int) As Boolean
' 'Sub DrawGIF(Frame As Int, Dest As Rect) As Boolean
' Dim tempstr As String = Filename
' If Filename.length >0 And Not(LockUniBMP) Then 'And Not(IsPaused(Main)) Then
' If Dir.Length>0 Then tempstr = File.Combine(Dir, Filename)
' If CenterPlatformID <> ElementType Or tempstr <> UNIFILE Or Not(GIFloaded) Then
' If Dir.Length=0 Then Dir = FindDIR(Dir,Filename)
' If Dir.Length>0 And File.Exists(Dir,Filename) Then
' CallSub3(Main, "LoadGIF", Dir, Filename)
' CenterPlatformID = ElementType
' UNIFILE=tempstr
' Log("Loaded: " & File.Combine(Dir, Filename))
' Return True
' End If
' End If
' End If
'End Sub
Sub LoadUniversalBMP(Dir As String, Filename As String, ElementType As Int) As Boolean
Dim tempstr As String = Filename
If Filename.length >0 And Not(LockUniBMP) Then
If Dir.Length>0 Then tempstr = File.Combine(Dir, Filename)
'Log(ElementType & " THISBMP: " & tempstr)
'Log(CenterPlatformID & " UNIFILE: " & UNIFILE)
If Not(CenterPlatform.IsInitialized ) Or CenterPlatformID <> ElementType Or tempstr <> UNIFILE Then
If Dir.Length=0 Then Dir = FindDIR(Dir,Filename)
If Dir.Length>0 And File.Exists(Dir,Filename) Then
Try
'If CenterPlatform.IsInitialized then BitMap.recycle
CenterPlatform.Initialize(Dir,Filename)
CenterPlatformID = ElementType
WasInit=True
UNIFILE=tempstr
Log("Loaded: " & File.Combine(Dir, Filename))
Return True
Catch
Return False
End Try
End If
End If
Return True
End If
End Sub
Sub ClearRandomNumbers
LCARSeffects3.RND_ID=0
LineList.Initialize
NumSection=0
Numbers.Initialize
LastAdditions.Initialize
ColumnList.Initialize
End Sub
Sub InitRandomNumbers(ElementType As Int, IncrementalUpdates As Boolean) As Boolean
If ElementType <> NumSection Or API.ListSize(LineList) = 0 Or API.ListSize(Numbers)=0 Then
'Log("Was: " & NumSection & " " & ElementType)
ClearRandomNumbers
ScrollingMode = False
Select Case ElementType
Case LCAR.CHX_Iconbar, LCAR.LCAR_RndNumbers
'ScrollingMode = True
End Select
NumSection=ElementType
RandomizeFullList = IncrementalUpdates
LastSecond= DateTime.GetSecond( DateTime.Now )
Return True
End If
Return False
End Sub
Sub SetColRowColorID(Row As Int, Col As Int, ColorID As Int)
Dim Rows As NumLis, Cols As NumCol
Rows = Numbers.Get(Row)
Cols = Rows.Columns.Get(Col)
Cols.ColorID=ColorID
End Sub
'Digits (-number has no padding), align (1=left -1=right)
Sub AddRowsOfNumbers(ID As Int,Rows As Int, ColorID As Int, Data As List)
Dim temp As Int
For temp = 1 To Rows
AddRowOfNumbers(ID, ColorID,Data)
Next
End Sub
Sub HasALine(ID As Int) As Boolean
Dim temp As Int , Row As NumLis
For temp = 0 To Numbers.Size-1
Row= Numbers.Get(temp)
If Row.ID = ID Then Return True
Next
End Sub
Sub FindLineIndex(ID As Int, First As Boolean) As Int
Dim temp As Int , Row As NumLis, LineIndex As Int = -1
For temp = 0 To Numbers.Size-1
Row= Numbers.Get(temp)
If Row.ID = ID Then
If First Then Return temp
LineIndex = temp
End If
Next
Return LineIndex
End Sub
Sub FindFirstLine(ID As Int,Index As Int) As NumLis
Dim temp As Int , Row As NumLis, LineIndex As Int
For temp = 0 To Numbers.Size-1
Row= Numbers.Get(temp)
If Row.ID = ID Then
If Index=LineIndex Then
Return Row
Else
LineIndex=LineIndex+1
End If
End If
Next
End Sub
Sub DuplicateFirstLines(ID As Int, Count As Int)
Dim temp As Int, Row As NumLis
Row = FindFirstLine(ID,0)
For temp = 1 To Count
DuplicateFirstLine(Row)
Next
End Sub
Sub DuplicateFirstLine(Src As NumLis)
Dim Row As NumLis , temp As Int
Row.Initialize
Row.id = Src.ID
Row.Columns.Initialize
Row.ColorID = Src.ColorID
For temp = 0 To Src.Columns.Size-1
Row.Columns.Add( Src.Columns.Get(temp) )
Next
RandomizeRow(Row)
AddLine(Src.ID )
Numbers.Add(Row)
End Sub
Sub DrawNumberBlock(BG As Canvas, X As Int, Y As Int, Width As Int, Height As Int, ColorID As Int, ID As Int, ElementType As Int, Text As String ) As Boolean
Dim Font As Typeface = LCAR.LCARfont, MaxSize As Int , Color As Int = Colors.Black , NeedsInit As Boolean , Textsize As Int = LCAR.Fontsize, ColInfo As NumSec
Select Case ElementType
Case LCAR.LCAR_WarpField: If ID>0 Then Textsize = Textsize * 0.5
Case LCAR.TMP_RndNumbers
Textsize = Textsize * 0.5
Font = StarshipFont
If ColorID = LCAR.LCAR_White Then Color = Colors.Transparent
Case LCAR.CHX_Window, LCAR.CHX_Iconbar
Font = LCARSeffects3.CHX_Font
If ElementType = LCAR.CHX_Window Then
Color = LCARSeffects3.CHX_Beige
Else
Color = Colors.Transparent ' LCARSeffects3.CHX_LightBlue
MaxSize = Width
End If
Case LCAR.ENT_RndNumbers
Font=Typeface.DEFAULT
Textsize = Textsize * 0.5
End Select
If InitRandomNumbers(ElementType, True) Then NeedsInit=True
If Color <> Colors.Transparent Then LCAR.DrawRect(BG,X,Y,Width+1,Height,Color, 0)
If ScrollingMode Then
If ID >= ColumnList.size Then
ColInfo.Initialize
ColInfo.Speed = Rnd(1, 5)'LineSize*0.25)
ColumnList.Add(ColInfo)
Else
ColInfo = ColumnList.Get(ID)
End If
Y=Y-ColInfo.Y
'Log("ColInfo: " & ColInfo)
End If
If DrawRandomNumbers(BG,X,Y+BG.MeasureStringHeight("0123", Font, Textsize), Font, Textsize, Width, Height, ID ) =0 Then
If API.debugMode And ElementType <> LCAR.CHX_Iconbar Then Text = "SYSTEM ERROR " & ElementType & " " & NumSection
If ElementType <> NumSection Then ClearRandomNumbers
'Else
NeedsInit = True
'End If
End If
If NeedsInit Then
If MaxSize = 0 Then MaxSize = Max(LCAR.ScaleHeight,LCAR.ScaleWidth)
MakeRowOfRandomNumbers(BG, Font, Textsize, MaxSize, ID, ColorID)
End If
If Text.Length >0 Then
Textsize=Textsize*2
MaxSize = BG.MeasureStringWidth(Text, LCAR.lcarfont, Textsize)
If MaxSize < Width Then
LCAR.DrawLCARtextbox(BG, X+Width+1, Y, -1, Textsize, -1,-1, Text, ColorID, 0,0, False,False, 3, 255)
Else
LCAR.DrawText(BG, X+Width+1, Y, Text, ColorID, 3,False,255,-1)
End If
End If
Return NeedsInit
End Sub
Sub MakeRowOfRandomNumbers(BG As Canvas, Font As Typeface, FontSize As Int, Width As Int, ID As Int, ColorID As Int)
Dim CharWidth As Int ,TotalWidth As Int, CurrentWidth As Int , Row As NumLis , Digits As Int, Align As Int
CharWidth = BG.MeasureStringWidth("0", Font,FontSize) + 1
Row.Initialize
Row.ID = ID
Row.Columns.Initialize
Row.ColorID = ColorID
Row.TotalWidth=Width
Do Until TotalWidth>=Width
If NumSection = LCAR.CHX_Iconbar Then
Align = BG.MeasureStringWidth("0", LCARSeffects3.CHX_Font, FontSize)
Digits = Width / Align
Else
Digits = Rnd(1,8)
If Rnd(0,2)=0 Then Digits = -Digits
Align= Rnd(-1,1)
End If
'CurrentWidth=(Abs(Digits)+2)*CharWidth
CurrentWidth= LCARSeffects7.DigitWidth(BG, Font, FontSize, Abs(Digits))
TotalWidth=TotalWidth+CurrentWidth
If TotalWidth > Width Then
Do Until TotalWidth <= Width Or Abs(Digits) = 0
If Digits > 0 Then Digits = Digits - 1 Else Digits = Digits + 1
TotalWidth = TotalWidth - CharWidth
Loop
End If
If Abs(Digits) > 0 Then Row.Columns.Add(AddColOfNumbers(Digits,Align))
Loop
RandomizeRow(Row)
AddLine(ID)
Numbers.Add(Row)
End Sub
'ID=Virtual ID, Data = array(Digits (-number has no padding), align (1=left -1=right))
Sub AddRowOfNumbers(ID As Int, ColorID As Int, Data As List)As Int
Dim Row As NumLis,temp As Int '10^digits
Row.Initialize
Row.ID = ID
Row.Columns.Initialize
For temp = 0 To Data.Size-1 Step 2
Row.Columns.Add (AddColOfNumbers(Data.Get(temp), Data.Get(temp+1)))
Next
Row.ColorID=ColorID
RandomizeRow(Row)
AddLine(ID)
Numbers.Add(Row)
Return Numbers.Size-1
End Sub
Sub AddColOfNumbers(Digits As Int, Align As Int) As NumCol
Dim temp As NumCol
temp.Initialize
temp.Digits=Digits
If NumSection = LCAR.ENT_RndNumbers Then
temp.ColorID = API.IIFIndex(Rnd(0,2), Array As Int(LCAR.LCAR_White, LCAR.LCAR_Red))
temp.Digits=-Digits
End If
temp.Align=Align
Return temp
End Sub
Sub IncrementNumbers As Boolean
Dim temp As Int , Line As NumLin,Row As NumLin ,Cols As NumLis ,temp2 As Int, ColInfo As NumSec', temp3 As Int, temp4 As Int
If Numbers.IsInitialized Then
'Log( DateTime.GetSecond( DateTime.Now ) & " " & LastSecond & " " & Numbers.Size )
If DateTime.GetSecond( DateTime.Now ) <> LastSecond Or Numbers.Size=0 Then
'API.SeedRND
LastSecond= DateTime.GetSecond( DateTime.Now )
If Not(RandomizeFullList) Then
For temp = 0 To Numbers.Size-1
RandomizeRow( Numbers.Get(temp) )
Next
Else
For temp = 0 To LineList.Size-1
Row = LineList.Get(temp)
Cols = FindFirstLine(temp, Row.RandomizeFullList)
RandomizeRow(Cols)
For temp2 = 0 To Row.Lines-1
If temp2 <> Row.RandomizeFullList Then
Cols = FindFirstLine(temp, temp2)
AgeRow(Cols)
End If
Next
Row.RandomizeFullList = (Row.RandomizeFullList+1) Mod Row.Lines
Next
End If
If LCAR.RedAlert Then
For temp = 0 To LineList.Size-1
Line = LineList.Get(temp)
Line.RedAlert = (Line.RedAlert+1) Mod Line.Lines
Next
End If
Return True
End If
If ScrollingMode Then
temp2 = LCAR.EmergencyBG.MeasureStringHeight("10", LCARSeffects3.CHX_Font, LCARSeffects3.CHX_Fontsize)'lineheight
For temp = 0 To ColumnList.Size
ColInfo = ColumnList.Get(temp)
ColInfo.y = ColInfo.Y + ColInfo.Speed
If ColInfo.y > temp2 Then
ColInfo.y = ColInfo.y Mod temp2
EraseLines(temp)
End If
Next
End If
End If
Return False
End Sub
Sub RandomizeRow(Row As NumLis)
Dim temp As Int, Col As NumCol , tempstr As String
If Not(Row = Null ) Then
Row.Values.Initialize
Row.Age=0
For temp = 0 To Row.Columns.Size-1
Col = Row.Columns.Get(temp)
If NumSection = LCAR.CHX_Window Or NumSection = LCAR.CHX_Iconbar Then
tempstr = MakeBinary(Abs(Col.Digits),NumSection = LCAR.CHX_Iconbar)
If NumSection = LCAR.CHX_Window Then
Row.Values.Add(tempstr)
Else
Row.Values.Add(Regex.Split(",", tempstr))
End If
Else If ForcedNumber = -1 Then
Row.Values.Add(RandomNumber(Abs(Col.Digits),Col.Digits>0))
Else
Row.Values.Add(MakeString(Abs(Col.Digits), ForcedNumber))
End If
Next
End If
End Sub
Sub MakeBinary(Digits As Int, Allow2 As Boolean) As String
Dim temp As Int, tempstr As StringBuilder, LastOne As Int
tempstr.Initialize
If Allow2 Then'I think I saw a 2
Do Until Digits = 0
temp = Rnd(0,API.IIF(LastOne=2,2,3))'prevent strings of blocks
If tempstr.Length > 0 Then tempstr.Append(",")
tempstr.Append(temp)
LastOne = temp
If temp = 2 Then
temp = Rnd(1, Digits)
tempstr.Append("," & temp)
Digits = Digits - temp
Else
Digits = Digits - 1
End If
Loop
Else'Don't worry Bender, there's no such thing as 2
For temp = 1 To Digits
tempstr.Append( Rnd(0,2) )
Next
End If
Return tempstr.ToString
End Sub
Sub MakeString(Digits As Int, Character As String) As String
Dim temp As Int, tempstr As StringBuilder
tempstr.Initialize
For temp = 1 To Digits
tempstr.Append(Character)
Next
Return tempstr.ToString
End Sub
Sub AgeRow(Row As NumLis)
If Row <> Null Then
If Row.IsInitialized Then Row.Age = Row.Age+1
End If
End Sub
Sub DrawRandomNumbers(BG As Canvas, X As Int, Y As Int,Font As Typeface, FontSize As Int, MaxWidth As Int, MaxHeight As Int, ID As Int ) As Int
Dim temp As Long, LineSize As Int , CharWidth As Int ,Height As Int, Src As NumLis, Curr As NumLis , Line As NumLin , CurrLin As Int, LineIndex As Int
Dim RedAlert As Boolean , DoBG As Boolean,Drawn As Boolean 'ColInfo As NumSec,
Try
LineSize=BG.MeasureStringHeight("1234567890", Font, FontSize)+2
If ID<0 Then
DoBG=True
Y=Y+LineSize-1
ID=Abs(ID)
End If
CharWidth = BG.MeasureStringWidth("0", Font,FontSize)
CurrLin=-1
For temp = 0 To Numbers.Size-1
Curr = Numbers.Get(temp)
'Log("Checking row: " & temp & " for ID " & ID & ", it was " & Curr.ID)
If Curr.ID = ID Then
'Log("Drawing row " & temp)
If LCAR.RedAlert Then
If CurrLin<> ID Then Line = LineList.Get(ID)
RedAlert = Line.RedAlert = LineIndex
End If
DrawRow(BG, X,Y, Font,FontSize,CharWidth, Curr, ID ,MaxWidth, RedAlert,DoBG,LineSize)
Drawn=True
Y=Y+LineSize
If MaxHeight>0 Then
If Not(Src.IsInitialized ) Then Src =Numbers.Get(temp)
Height=Height+LineSize
If Height>MaxHeight Then Exit
End If
LineIndex=LineIndex+1
End If
Next
If MaxHeight>0 And Height+LineSize<=MaxHeight And Src.IsInitialized Then'add more
CharWidth=0
If NumSection = LCAR.ENT_RndNumbers Then'only add 1 per second
ForceListItems(LastAdditions, ID)
temp = LastAdditions.Get(ID)
'LogColor(ID & ": " & temp, Colors.Blue)
If LastAdditions.Get(ID) > DateTime.Now - DateTime.TicksPerSecond*0.25 Then CharWidth= API.IIF(HasALine(ID), 1,0)
End If
If CharWidth =0 Then
For temp = Height To MaxHeight Step LineSize
Height=Height+LineSize
If Height< MaxHeight Then
DuplicateFirstLine(Src)
CharWidth=CharWidth+1
End If
If NumSection = LCAR.ENT_RndNumbers Then
LastAdditions.Set(ID, DateTime.Now)
temp = MaxHeight + LineSize 'only add 1 per second
End If
Next
End If
Else If NumSection = LCAR.ENT_RndNumbers Then
EraseLines(ID)'clear when full and start over
End If
Catch
Log(LastException.Message)
End Try
If Drawn Then
Return LineSize
Else
Return 0
End If
End Sub
Sub ForceListItems(Lst As List, Size As Int)
If Not(Lst.IsInitialized) Then Lst.Initialize
Do Until Lst.Size > Size
Lst.Add(0)
Loop
End Sub
Sub EraseLines(ID As Int)
Dim temp As Int, Curr As NumLis
Select Case NumSection
Case LCAR.ENT_RndNumbers
For temp = Numbers.Size-1 To 0 Step -1
Curr = Numbers.Get(temp)
If Curr.ID = ID Then Numbers.RemoveAt(temp)
Next
Case LCAR.CHX_Iconbar
If ScrollingMode Then
temp = FindLineIndex(ID, True)
If temp>-1 Then Numbers.RemoveAt(temp)
End If
End Select
End Sub
Sub DrawRow(BG As Canvas, X As Int, Y As Int, Font As Typeface, FontSize As Int, CharWidth As Int, Row As NumLis, ID As Int, MaxWidth As Int, RedAlert As Boolean, DoBackGround As Boolean, LineHeight As Int) As Boolean
Dim temp As Int , Col As NumCol,Text As String, Color As Int ,Width As Int,State As Boolean
If Row.ID = ID Then
If MaxWidth>0 Then MaxWidth=MaxWidth+X
For temp = 0 To Row.Columns.size-1
Col = Row.Columns.Get(temp)
If NumSection <> LCAR.CHX_Iconbar Then Text = Row.Values.Get(temp)
'Width = Abs(Col.Digits) * (CharWidth+2)
Width = LCARSeffects7.DigitWidth(BG, Font, FontSize, Abs(Col.Digits))
Do While X + Width > MaxWidth And Col.Digits <> 0
If Col.Digits < 0 Then Col.Digits = Col.Digits + 1 Else Col.Digits = Col.Digits - 1
If Col.Digits = 0 Then Return False
Width = LCARSeffects7.DigitWidth(BG, Font, FontSize, Abs(Col.Digits))
Loop
If RedAlert Then
State= True
Else
State= (Row.age<2) And RandomizeFullList
End If
If LCAR.RedAlert Then
Color = LCAR.LCAR_RedAlert
If Not(State) Then Color = LCAR.RedAlertMode
Else
Color = API.IIF(Col.ColorID =0, Row.ColorID,Col.ColorID)
End If
'Log("Col " & temp & " = " & Text & " - " & Color)
If Color <0 Then' -1 -2 -3 -4 -5 -6
Color = API.IIFIndex(Abs(Color)-1, Array As Int(LCARSeffects3.CHX_Beige, LCARSeffects3.CHX_DarkBlue, LCARSeffects3.CHX_DarkRed, LCARSeffects3.CHX_LightBeige, LCARSeffects3.CHX_LightBlue, LCARSeffects3.CHX_LightRed))
Else
Color = LCAR.GetColor(Color, State, 255)
End If
If DoBackGround Then LCAR.DrawRect(BG, X,Y-LineHeight ,Width-2,LineHeight+2, Colors.black , 0)
If NumSection = LCAR.CHX_Iconbar Then'supports (=======) blocks
DrawCHXline(BG, X,Y,CharWidth,LineHeight,Row.Values.Get(temp), Font,FontSize, Color)'NOT A STRING!
Else If Col.Align=-1 Then'right align
BG.DrawText(Text, X+Width,Y,Font, FontSize, Color, "RIGHT")
Else'left align
BG.DrawText(Text, X,Y,Font, FontSize, Color, "LEFT")
End If
X=X+Width+CharWidth
If X>= MaxWidth And MaxWidth>0 Then temp=Row.Columns.size
Next
'If MaxWidth-x > CharWidth*4 Then AddColOfNumbers( End If
Return True
End If
Return False
End Sub
Sub DrawCHXline(BG As Canvas, X As Int, Y As Int, CharWidth As Int, LineHeight As Int, tempstr() As String, Font As Typeface, FontSize As Int, Color As Int)
Dim Text As Int, temp As Int, Cols As Int, WhiteY As Int = 4
For temp = 0 To tempstr.Length - 1
Text = tempstr(temp)
'Log("DrawCHXline: " & Text)
If Text = 2 Then'block
Cols = tempstr(temp+1)
LCAR.DrawRoundedRectangle(BG,X,Y-LineHeight+WhiteY,Cols*CharWidth,LineHeight-WhiteY, 2, Color, 0)
temp=temp+1
X=X+CharWidth*Cols
Else
BG.DrawText(Text, X,Y,Font, FontSize, Color, "LEFT")
X=X+CharWidth
End If
Next
End Sub
Sub AddLine(ID As Int)
Dim Line As NumLin
If ID < LineList.Size Then
Line = LineList.Get(ID)
Line.Lines = Line.Lines+1
Else
Line.Initialize
Line.Lines=1
LineList.Add(Line)
End If
'Log("ID: " & ID & " has " & Line.Lines )
End Sub
Sub InitAdvDrawingStuff
If Not(isAdvInit) Then
mMatrix.Initialize
mPaint.Initialize
mPaint.SetAntiAlias(LCAR.AntiAliasing)
mPaint.SetFilterBitmap(LCAR.AntiAliasing)
isAdvInit=True
End If
End Sub
Sub DrawTrapezoid(BG As Canvas, BMP As Bitmap ,SRC As Rect , X As Int, Y As Int, TopWidth As Int, BottomWidth As Int, Height As Int, Alpha As Int)
Dim BottomLeft As Int ,P As Path, DoClip As Boolean = Height>0
If TopWidth = BottomWidth Then
DrawBMP(BG, BMP, SRC.Left, SRC.Top, SRC.Right-SRC.Left, SRC.Bottom-SRC.Top, X,Y,TopWidth,Height,Alpha,False,False)
Else
Height = Abs(Height)
LCAR.ExDraw.save2(BG, LCAR.ExDraw.MATRIX_SAVE_FLAG)
If TopWidth=0 Then TopWidth=BottomWidth
If BottomWidth=0 Then BottomWidth=TopWidth
If BottomWidth> TopWidth Then X = X + (BottomWidth-TopWidth)/2
BottomLeft = X+ TopWidth/2 - BottomWidth/2
If SRC=Null Or Not(SRC.IsInitialized) Then SRC.Initialize(0,0, BMP.Width, BMP.Height)
mPaint.Initialize
mPaint.SetAlpha(Alpha)
mMatrix.setPolyToPoly( Array As Float(SRC.Left,SRC.Top, SRC.Right,SRC.Top, SRC.Right, SRC.Bottom, SRC.Left,SRC.Bottom), 0, Array As Float( X,Y, X+TopWidth,Y, BottomLeft+BottomWidth, Y+Height, BottomLeft, Y+Height ), 0,4)
If DoClip Then
P.Initialize(X,Y)
P.LineTo(X+TopWidth,Y)
P.LineTo(BottomLeft+BottomWidth, Y+Height)
P.LineTo(BottomLeft, Y+Height)
BG.ClipPath(P)
End If
LCAR.ExDraw.drawBitmap4(BG, BMP, mMatrix, mPaint)
LCAR.ExDraw.restore(BG) 'before Activity.Invalidate
If DoClip Then BG.RemoveClip
End If
End Sub
'SRC and DEST are an array of X/Y coordinates
Sub DrawBMPpoly(BG As Canvas, BMP As Bitmap, SRC() As Float, DEST() As Float, Alpha As Int, NeedsClipPath As Boolean)
Dim temp As Int, P As Path
If SRC.Length = DEST.Length Then
LCAR.ExDraw.save2(BG, LCAR.ExDraw.MATRIX_SAVE_FLAG)
mPaint.Initialize
mPaint.SetAlpha(Alpha)
mMatrix.setPolyToPoly(SRC, 0, DEST, 0, DEST.Length *0.5)
If API.debugMode Then
BG.DrawLine(DEST(0),DEST(1), DEST( DEST.Length-2),DEST( DEST.Length-1), Colors.Blue,3)
For temp = 0 To DEST.Length -3 Step 2
BG.DrawLine(DEST(temp),DEST(temp+1), DEST(temp+2),DEST(temp+3), Colors.Red, 3)
Next
End If
If NeedsClipPath Then
P.Initialize(DEST(0),DEST(1))
For temp = 2 To DEST.Length -1 Step 2
P.LineTo(DEST(temp),DEST(temp+1))
Next
BG.ClipPath(P)
End If
LCAR.ExDraw.drawBitmap4(BG, BMP, mMatrix, mPaint)
LCAR.ExDraw.restore(BG) 'before Activity.Invalidate
If NeedsClipPath Then BG.RemoveClip
End If
End Sub
Sub DrawBMP(BG As Canvas, BMP As Bitmap, SrcX As Int, SrcY As Int, SrcWidth As Int, SrcHeight As Int, X As Int, Y As Int, Width As Int, Height As Int, Alpha As Int, FlipX As Boolean, FlipY As Boolean)
Dim Dest() As Float ,Right As Int, Bottom As Int, NeedsClip As Boolean = SrcX <> 0 Or SrcY<> 0
If SrcWidth=0 Then SrcWidth = BMP.Width -SrcX
If SrcHeight=0 Then SrcHeight=BMP.Height - SrcY
If Alpha = 255 Then
If FlipX Or FlipY Then
BG.DrawBitmapFlipped(BMP, LCARSeffects4.SetRect(SrcX,SrcY,SrcWidth,SrcHeight), LCARSeffects4.SetRect(X,Y,Width,Height), FlipY, FlipX)
Else
BG.DrawBitmap(BMP, LCARSeffects4.SetRect(SrcX,SrcY,SrcWidth,SrcHeight), LCARSeffects4.SetRect(X,Y,Width,Height))
End If
Else If Alpha>0 Then
If SrcWidth <> BMP.Width Or SrcHeight <> BMP.Height Then NeedsClip = True
LCAR.ExDraw.save2(BG, LCAR.ExDraw.MATRIX_SAVE_FLAG)
mPaint.Initialize
mPaint.SetAlpha(Alpha)
Right=X+Width
Bottom=Y+Height
If FlipX And FlipY Then
Dest=Array As Float(Right,Bottom, X,Bottom, X,Y, Right,Y)
Else If FlipX Then
Dest=Array As Float(Right,Y, X,Y, X,Bottom, Right,Bottom)
Else If FlipY Then
Dest=Array As Float(X,Bottom, Right,Bottom, Right,Y, X,Y)
Else
Dest=Array As Float(X,Y, Right,Y, Right, Bottom, X,Bottom )
End If
mMatrix.Initialize
If NeedsClip Then LCARSeffects.MakeClipPath(BG,X,Y,Width,Height)
mMatrix.setPolyToPoly( Array As Float(SrcX,SrcY, SrcX+SrcWidth, SrcY, SrcX+SrcWidth,SrcY+SrcHeight, SrcX,SrcY+SrcHeight), 0, Dest, 0,4)
LCAR.ExDraw.drawBitmap4(BG, BMP, mMatrix, mPaint)
LCAR.ExDraw.restore(BG)
If NeedsClip Then BG.RemoveClip
End If
End Sub
Sub SetupShine(RotationX As Float)
Dim cosRotation As Double, intensity As Int, highlightIntensity As Int, light As Int, highlight As Int
cosRotation = Cos(Trig.PI * RotationX / 180)
intensity = Min(MAX_INTENSITY, AMBIENT_LIGHT + (DIFFUSE_LIGHT * cosRotation))
highlightIntensity = Min(MAX_INTENSITY, SPECULAR_LIGHT * Power(cosRotation,SHININESS))
light = Colors.rgb(intensity, intensity, intensity)
highlight = Colors.rgb(highlightIntensity, highlightIntensity, highlightIntensity)
mPaint.SetLightingColorFilter(light, highlight)
End Sub
Sub AddPToELine(Y As Int)As PtoELine
Dim temp2 As PtoELine
temp2.Initialize
temp2.Y=Y
temp2.Cols.Initialize
Elements.Add(temp2)
Return temp2
End Sub
Sub AddPToElement(X As Int, Y As Int, Molecule As String, AtomicSymbol As String, AtomicWeight As Double, ElectronConfiguration As String ,ElectronsPerShell As String,ColorID As Int )As PToElement
Dim temp As PToElement ,temp2 As PtoELine
If Not(API.TransLanguage.EqualsIgnoreCase("english")) Then
If API.Translation.ContainsKey("ptoe_" & Molecule.ToLowerCase) Then Molecule = API.GetString("ptoe_" & Molecule.ToLowerCase)
If API.Translation.ContainsKey("ptoe_" & AtomicSymbol.ToLowerCase) Then Molecule = API.GetString("ptoe_" & AtomicSymbol.ToLowerCase)
End If
If Molecule.Length > PTOE_Longest.Length Then PTOE_Longest = Molecule
Y=Y-1
PToExtCache=PToExtCache+1
If Elements.IsInitialized Then
If Elements.Size=0 Then
temp2=AddPToELine(0)
Else
temp2 = Elements.Get( Elements.Size-1)
If temp2.Y <> Y Then temp2= AddPToELine(Y)
End If
Else
Elements.Initialize
temp2=AddPToELine(0)
End If
temp.Initialize
temp.X =X-1
temp.AtomicNumber=PToExtCache
temp.Molecule =Molecule.ToUpperCase
temp.AtomicSymbol =AtomicSymbol
temp.AtomicWeight = AtomicWeight
temp.ElectronConfiguration =ElectronConfiguration.replace("] ", "]")
temp.ElectronsPerShell = ElectronsPerShell.Replace(",", "")
If PToExtCache<>119 Then
temp.Color = LCAR.GetColor(ColorID,False,255)
Else
temp.Color = Colors.Red
End If
temp2.Cols.Add(temp)
Return temp
End Sub
Sub SetupElements(Mode As Int)
Dim R As Int,S As Int
If Elements.IsInitialized Then Elements.Clear
PToExtCache=0
PTOE_Longest=""
If Mode=0 Then
AddPToElement( 1, 1, "HYDROGEN", "H", 1.008, "1s1", "1", LCAR.LCAR_DarkYellow)
AddPToElement(18, 1, "HELIUM", "He", 4.003, "1s2", "2", LCAR.LCAR_Red)
AddPToElement( 1, 2, "LITHIUM", "Li", 6.941, "1s2 2s1", "2 1", LCAR.LCAR_DarkPurple )
AddPToElement( 2, 2, "beryllium", "Be", 9.012, "1s2 2s2", "2 2", LCAR.LCAR_Orange )
AddPToElement(13, 2, "boron", "B", 10.811, "[He]2s2 2p1", "2 3", LCAR.LCAR_DarkYellow)
AddPToElement(14, 2, "Carbon", "C", 12.011, "[He]2s2 2p2", "2 4", LCAR.LCAR_DarkYellow)
AddPToElement(15, 2, "Nitrogen", "N", 14.007, "1s2 2s2 2p3", "2 5", LCAR.LCAR_DarkYellow)
AddPToElement(16, 2, "Oxygen", "O", 15.999, "1s2 2s2 2p4", "2 6", LCAR.LCAR_DarkYellow)
AddPToElement(17, 2, "Flourine", "F", 18.998, "1s2 2s2 2p5", "2 7", LCAR.LCAR_DarkPurple)
AddPToElement(18, 2, "Neon", "Ne", 20.180, "1s2 2s2 2p6", "2 8", LCAR.LCAR_Red)
AddPToElement( 1, 3, "Sodium", "Na", 22.990, "[Ne]3s1", "2 8 1", LCAR.LCAR_DarkPurple )
AddPToElement( 2, 3, "magnesium", "Mg", 24.305, "[Ne]3s2", "2 8 2", LCAR.LCAR_Orange )
AddPToElement(13, 3, "aluminium", "Al", 26.982, "[Ne]3s2 3p1", "2 8 3", LCAR.LCAR_Purple )
AddPToElement(14, 3, "silicon", "Si", 28.086, "[Ne]3s2 3p2", "2 8 4", LCAR.LCAR_DarkYellow)
AddPToElement(15, 3, "phosphorus", "P", 30.974, "[Ne]3s2 3p3", "2 8 5", LCAR.LCAR_DarkYellow)
AddPToElement(16, 3, "sulfur", "S", 32.065, "[Ne]3s2 3p4", "2 8 6", LCAR.LCAR_DarkYellow)
AddPToElement(17, 3, "chlorine", "Cl", 35.453, "[Ne]3s2 3p5", "2 8 7", LCAR.LCAR_LightPurple)
AddPToElement(18, 3, "argon", "Ar", 39.948, "[Ne]3s2 3p6", "2 8 8", LCAR.LCAR_Red)
AddPToElement( 1, 4, "Potassium", "K", 39.098, "[Ar]4s1", "2 8 8 1", LCAR.LCAR_DarkPurple )
AddPToElement( 2, 4, "Calcium", "Ca", 40.078, "[Ar]4s2", "2 8 8 2", LCAR.LCAR_Orange )
AddPToElement( 3, 4, "scandium", "Sc", 44.956, "[Ar]3d1 4s2", "2 8 9 2", LCAR.LCAR_Yellow)
AddPToElement( 4, 4, "titanium", "Ti", 47.867, "[Ar]4s2 3d2", "2 8 10 2", LCAR.LCAR_Yellow)
AddPToElement( 5, 4, "Vanadium", "V", 50.942, "[Ar]3d3 4s2", "2 8 11 2", LCAR.LCAR_Yellow)
AddPToElement( 6, 4, "Chromium", "Cr", 51.996, "[Ar]4s1 3d5", "2 8 13 1", LCAR.LCAR_Yellow)
AddPToElement( 7, 4, "manganese", "Mn", 54.938, "[Ar]4s2 3d5", "2 8 13 2", LCAR.LCAR_Yellow)
AddPToElement( 8, 4, "iron", "Fe", 55.845, "[Ar]3d6 4s2", "2 8 14 2", LCAR.LCAR_Yellow)
AddPToElement( 9, 4, "cobalt", "Co", 58.933, "[Ar]4s2 3d7", "2 8 15 2", LCAR.LCAR_Yellow)
AddPToElement(10, 4, "nickel", "Ni", 58.693, "[Ar]4s2 3d8", "2 8 16 2", LCAR.LCAR_Yellow)
AddPToElement(11, 4, "copper", "Cu", 63.546, "[Ar]3d10 4s1", "2 8 18 1", LCAR.LCAR_Yellow)
AddPToElement(12, 4, "zinc", "Zn", 65.380, "[Ar]3d10 4s2", "2 8 18 2", LCAR.LCAR_Yellow)
AddPToElement(13, 4, "gallium", "Ga", 69.723, "[Ar]4s2 3d10 4p1", "2 8 18 3", LCAR.LCAR_Purple )
AddPToElement(14, 4, "germanium", "Ge", 72.630, "[Ar]3d10 4s2 4p2", "2 8 18 4", LCAR.LCAR_Purple )
AddPToElement(15, 4, "arsenic", "As", 74.922, "[Ar]4s2 3d10 4p3", "2 8 18 5", LCAR.LCAR_DarkYellow)
AddPToElement(16, 4, "selenium", "Se", 78.971, "[Ar]3d10 4s2 4p4", "2 8 18 6", LCAR.LCAR_DarkYellow )
AddPToElement(17, 4, "bromine", "Br", 79.904, "[Ar]4s2 3d10 4p5", "2 8 18 7", LCAR.LCAR_LightPurple )
AddPToElement(18, 4, "krypton", "Kr", 83.798, "[Ar]3d10 4s2 4p6", "2 8 18 8", LCAR.LCAR_Red)
AddPToElement( 1, 5, "rubidium", "Rb", 85.468, "[Kr]5s1", "2 8 18 8 1", LCAR.LCAR_DarkPurple )
AddPToElement( 2, 5, "strontium", "Sr", 87.620, "[Kr]5s2", "2 8 18 8 2", LCAR.LCAR_Orange )
AddPToElement( 3, 5, "yttrium", "Y", 88.906, "[Kr]4d1 5s2", "2 8 18 9 2", LCAR.LCAR_Yellow)
AddPToElement( 4, 5, "zirconium", "Zr", 91.224, "[Kr]5s2 4d2", "2 8 18 10 2", LCAR.LCAR_Yellow)
AddPToElement( 5, 5, "Niobium", "Nb", 92.906, "[Kr]4d4 5s1", "2 8 18 12 1", LCAR.LCAR_Yellow)
AddPToElement( 6, 5, "molybdenum", "Mo", 95.951, "[Kr]5s1 4d5", "2 8 18 13 1", LCAR.LCAR_Yellow)
AddPToElement( 7, 5, "technetium", "Tc", 98.000, "[Kr]4d5 5s2", "2 8 18 13 2", LCAR.LCAR_Yellow)
AddPToElement( 8, 5, "ruthenium", "Ru", 101.070, "[Kr]4d7 5s1", "2 8 18 15 1", LCAR.LCAR_Yellow)
AddPToElement( 9, 5, "rhodium", "Rh", 102.906, "[Kr]5s1 4d8", "2 8 18 16 1", LCAR.LCAR_Yellow)
AddPToElement(10, 5, "palladium", "Pd", 106.420, "[Kr]4d10", "2 8 18 18", LCAR.LCAR_Yellow)
AddPToElement(11, 5, "silver", "Ag", 107.868, "[Kr]4d10 5s1", "2 8 18 18 1", LCAR.LCAR_Yellow)
AddPToElement(12, 5, "cadmium", "Cd", 112.414, "[Kr]5s2 4d10", "2 8 18 18 2", LCAR.LCAR_Yellow)
AddPToElement(13, 5, "indium", "In", 114.818, "[Kr]4d10 5s2 5p1", "2 8 18 18 3", LCAR.LCAR_Purple )
AddPToElement(14, 5, "tin", "Sn", 118.710, "[Kr]4d10 5s2 5p2", "2 8 18 18 4", LCAR.LCAR_Purple )
AddPToElement(15, 5, "antimony", "Sb", 121.760, "[Kr]4d10 5s2 5p3", "2 8 18 18 5", LCAR.LCAR_Purple )
AddPToElement(16, 5, "tellurium", "Te", 127.600, "[Kr]4d10 5s2 5p4", "2 8 18 18 6", LCAR.LCAR_DarkYellow)
AddPToElement(17, 5, "iodine", "I", 126.904, "[Kr]4d10 5s2 5p5", "2 8 18 18 7", LCAR.LCAR_LightPurple)
AddPToElement(18, 5, "xenon", "Xe", 131.293, "[Kr]5s2 4d10 5p6", "2 8 18 18 8", LCAR.LCAR_Red)
AddPToElement( 1, 6, "caesium", "Cs", 132.905, "[Xe]6s1", "2 8 18 18 8 1", LCAR.LCAR_DarkPurple )
AddPToElement( 2, 6, "barium", "Ba", 137.330, "[Xe]6s2", "2 8 18 18 8 2", LCAR.LCAR_Orange )
AddPToElement( 3, 6, "lanthanum", "La", 138.905, "[Xe]5d1 6s2", "2 8 18 18 9 2", LCAR.LCAR_Yellow):PToExtCache=71
AddPToElement( 4, 6, "hafnium", "Hf", 178.490, "[Xe]4f14 5d2 6s2", "2 8 18 32 10 2", LCAR.LCAR_Yellow)
AddPToElement( 5, 6, "tantalum", "Ta", 180.948, "[Xe]4f14 5d3 6s2", "2 8 18 32 11 2", LCAR.LCAR_Yellow)
AddPToElement( 6, 6, "tungsten", "W", 183.840, "[Xe]4f14 5d4 6s2", "2 8 18 32 12 2", LCAR.LCAR_Yellow)
AddPToElement( 7, 6, "rhenium", "Re", 186.207, "[Xe]4f14 5d5 6s2", "2 8 18 32 13 2", LCAR.LCAR_Yellow)
AddPToElement( 8, 6, "osmium", "Os", 190.230, "[Xe]4f14 5d6 6s2", "2 8 18 32 14 2", LCAR.LCAR_Yellow)
AddPToElement( 9, 6, "iridium", "Ir", 192.217, "[Xe]4f14 5d7 6s2", "2 8 18 32 15 2", LCAR.LCAR_Yellow)
AddPToElement(10, 6, "platinum", "Pt", 195.084, "[Xe]4f14 5d9 6s1", "2 8 18 32 17 1", LCAR.LCAR_Yellow)
AddPToElement(11, 6, "Gold", "Au", 196.967, "[Xe]4f14 5d10 6s1", "2 8 18 32 18 1", LCAR.LCAR_Yellow)
AddPToElement(12, 6, "mercury", "Hg", 200.592, "[Xe]4f14 5d10 6s2", "2 8 18 32 18 2", LCAR.LCAR_Yellow)
AddPToElement(13, 6, "thallium", "Tl", 204.383, "[Xe]4f14 5d10 6s2 6p1","2 8 18 32 18 3", LCAR.LCAR_Purple )
AddPToElement(14, 6, "lead", "Pb", 207.200, "[Xe]4f14 5d10 6s2 6p2","2 8 18 32 18 4", LCAR.LCAR_Purple )
AddPToElement(15, 6, "bismuth", "Bi", 208.980, "[Xe]4f14 5d10 6s2 6p3","2 8 18 32 18 5", LCAR.LCAR_Purple )
AddPToElement(16, 6, "polonium", "Po", 209.000, "[Xe]6s2 4f14 5d10 6p4","2 8 18 32 18 6", LCAR.LCAR_Purple )
AddPToElement(17, 6, "astatine", "At", 210.000, "[Xe]4f14 5d10 6s2 6p5","2 8 18 32 18 7", LCAR.LCAR_LightPurple)
AddPToElement(18, 6, "radon", "Rn", 222.000, "[Xe]4f14 5d10 6s2 6p6","2 8 18 32 18 8", LCAR.LCAR_Red)
AddPToElement( 1, 7, "francium", "Fr", 223.000, "[Rn]7s1", "2 8 18 32 18 8 1", LCAR.LCAR_DarkPurple )
AddPToElement( 2, 7, "radium", "Ra", 226.030, "[Rn]7s2", "2 8 18 32 18 8 2", LCAR.LCAR_Orange )
AddPToElement( 3, 7, "actinium", "Ac", 227.000, "[Rn]6d1 7s2", "2 8 18 32 18 9 2", LCAR.LCAR_Yellow):PToExtCache=103
AddPToElement( 4, 7, "rutherfordium", "Rf", 267.000, "[Rn]5f14 6d2 7s2", "2 8 18 32 32 10 2",LCAR.LCAR_Yellow)
AddPToElement( 5, 7, "dubnium", "Db", 268.000, "[Rn]5f14 6d3 7s2", "2 8 18 32 32 11 2",LCAR.LCAR_Yellow)
AddPToElement( 6, 7, "seaborgium", "Sg", 269.000, "[Rn]7s2 5f14 6d4", "2 8 18 32 32 12 2",LCAR.LCAR_Yellow)
AddPToElement( 7, 7, "bohrium", "Bh", 270.000, "[Rn]5f14 6d5 7s2", "2 8 18 32 32 13 2",LCAR.LCAR_Yellow)
AddPToElement( 8, 7, "hassium", "Hs", 269.000, "[Rn]5f14 6d6 7s2", "2 8 18 32 32 14 2",LCAR.LCAR_Yellow)
AddPToElement( 9, 7, "meitnerium", "Mt", 278.000, "[Rn]7s2 5f14 6d7", "2 8 18 32 32 15 2",LCAR.LCAR_Yellow)
AddPToElement(10, 7, "darmstadtium", "Ds", 281.000, "[Rn]7s2 5f14 6d8", "2 8 18 32 32 16 2",LCAR.LCAR_Yellow)
AddPToElement(11, 7, "roentgenium","Rg", 281.000, "[Rn]5f14 6d9 7s2", "2 8 18 32 32 17 2",LCAR.LCAR_Yellow)
AddPToElement(12, 7, "copernicium","Cn", 285.000, "[Rn]5f14 6d10 7s2", "2 8 18 32 32 18 2",LCAR.LCAR_Yellow)
AddPToElement(13, 7, "nihonium", "Nh", 286.000, "[Rn]5f14 6d10 7s2 7p1","2 8 18 32 32 18 3",LCAR.LCAR_White)'113
AddPToElement(14, 7, "flerovium", "Fl", 289.000, "[Rn]5f14 6d10 7s2 7p2","2 8 18 32 32 18 4",LCAR.LCAR_White)'114
AddPToElement(15, 7, "moscovium", "Mc", 288.000, "[Rn]5f14 6d10 7s2 7p3","2 8 18 32 32 18 5",LCAR.LCAR_White)'115
AddPToElement(16, 7, "livermorium","Lv", 293.000, "[Rn]5f14 6d10 7s2 7p4","2 8 18 32 32 18 6",LCAR.LCAR_White)'116
AddPToElement(17, 7, "tennessine", "Ts", 294.000, "[Rn]5f14 6d10 7s2 7p5","2 8 18 32 32 18 7",LCAR.LCAR_White)'117
AddPToElement(18, 7, "oganesson", "Og", 294.000, "[Rn]5f14 6d10 7s2 7p6","2 8 18 32 32 18 8",LCAR.LCAR_White)'118
AddPToElement(18, 8, "RODDENBERRIUM", "Gr", 1996.00, "[ST]TOS3 TNG7", "3 7", -Colors.red):PToExtCache=57
AddPToElement( 3, 9, "cerium", "Ce", 140.116, "[Xe]4f 5d 6s2", "2 8 18 19 9 2", LCAR.LCAR_DarkOrange)
AddPToElement( 4, 9, "praseodymium", "Pr", 140.908, "[Xe]4f3 6s2", "2 8 18 21 8 2", LCAR.LCAR_DarkOrange)
AddPToElement( 5, 9, "neodymium", "Nd", 144.242, "[Xe]4f4 6s2", "2 8 18 22 8 2", LCAR.LCAR_DarkOrange)
AddPToElement( 6, 9, "promethium", "Pm", 145.000, "[Xe]4f5 6s2", "2 8 18 23 8 2", LCAR.LCAR_DarkOrange)
AddPToElement( 7, 9, "samarium", "Sm", 150.360, "[Xe]6s2 4f6", "2 8 18 24 8 2", LCAR.LCAR_DarkOrange)
AddPToElement( 8, 9, "europium", "Eu", 151.964, "[Xe]4f7 6s2", "2 8 18 25 8 2", LCAR.LCAR_DarkOrange)
AddPToElement( 9, 9, "gadolinium", "Gd", 157.250, "[Xe]4f7 5d1 6s2", "2 8 18 25 9 2", LCAR.LCAR_DarkOrange)
AddPToElement(10, 9, "terbium", "Tb", 158.925, "[Xe]4f9 6s2", "2 8 18 27 8 2", LCAR.LCAR_DarkOrange)
AddPToElement(11, 9, "dysprosium", "Dy", 162.500, "[Xe]4f10 6s2", "2 8 18 28 8 2", LCAR.LCAR_DarkOrange)
AddPToElement(12, 9, "holmium", "Ho", 164.930, "[Xe]4f11 6s2", "2 8 18 29 8 2", LCAR.LCAR_DarkOrange)
AddPToElement(13, 9, "erbium", "Er", 167.259, "[Xe]4f12 6s", "2 8 18 30 8 2", LCAR.LCAR_DarkOrange)
AddPToElement(14, 9, "thulium", "Tm", 168.934, "[Xe]4f13 6s2", "2 8 18 31 8 2", LCAR.LCAR_DarkOrange)
AddPToElement(15, 9, "ytterbium", "Yb", 173.055, "[Xe]4f14 6s2", "2 8 18 32 8 2", LCAR.LCAR_DarkOrange)
AddPToElement(16, 9, "lutetium", "Lu", 174.967, "[Xe]6s2 4f14 5d1", "2 8 18 32 9 2", LCAR.LCAR_DarkOrange):PToExtCache=89
AddPToElement( 3, 10, "thorium", "Th", 232.038, "[Rn]6d2 7s2", "2 8 18 32 18 10 2",LCAR.LCAR_DarkOrange)
AddPToElement( 4, 10, "protactinium", "Pa", 231.036, "[Rn]5f2 6d1 7s2", "2 8 18 32 20 9 2", LCAR.LCAR_DarkOrange)
AddPToElement( 5, 10, "uranium", "U", 238.029, "[Rn]5f3 6d1 7s2", "2 8 18 32 21 9 2", LCAR.LCAR_DarkOrange)
AddPToElement( 6, 10, "neptunium", "Np", 237.000, "[Rn]5f4 6d1 7s2", "2 8 18 32 22 9 2", LCAR.LCAR_DarkOrange)
AddPToElement( 7, 10, "plutonium", "Pu", 244.000, "[Rn]5f6 7s2", "2 8 18 32 24 8 2", LCAR.LCAR_DarkOrange)
AddPToElement( 8, 10, "americium", "Am", 243.000, "[Rn]5f7 7s2", "2 8 18 32 25 8 2", LCAR.LCAR_DarkOrange)
AddPToElement( 9, 10, "curium", "Cm", 247.000, "[Rn]5f7 6d1 7s2", "2 8 18 32 25 9 2", LCAR.LCAR_DarkOrange)
AddPToElement(10, 10, "berkelium", "Bk", 247.000, "[Rn]5f9 7s2", "2 8 18 32 27 8 2", LCAR.LCAR_DarkOrange)
AddPToElement(11, 10, "californium","Cf", 251.000, "[Rn]5f10 7s2", "2 8 18 32 28 8 2", LCAR.LCAR_DarkOrange)
AddPToElement(12, 10, "einsteinium","Es", 252.000, "[Rn]5f11 7s2", "2 8 18 32 29 8 2", LCAR.LCAR_DarkOrange)