GraphicsWindow.Title = "Crystal Structure of Salt"
scale = 0.47
Init()
mol = "NaCl"
DrawMolecularName()
distance = (atom["Na"]["+"] + atom["Cl"]["-"]) * scale
cols = 5
rows = 5
For row = 1 To rows
For col = 1 To cols
If Math.Remainder(row - col, 2) = 0 Then
' draw Na
ion = "+"
a = "Na"
Else
' draw Cl
ion = "-"
a = "Cl"
EndIf
ox = cx - (col - (cols + 1) / 2) * distance
oy = cy - (row - (rows + 1) / 2) * distance
bc = "#11000000"
opt = ""
size = atom[a][ion] * 2 * scale
FillCircle()
opt = ion
bc = atom[a]["color"]
size = atom[a]["size"] * scale
FillCircle()
EndFor
EndFor
Sub DrawLine
GraphicsWindow.PenColor = pc
If n = 2 Then
GraphicsWindow.PenWidth = 12
GraphicsWindow.DrawLine(x1, y1, x2, y2)
GraphicsWindow.PenColor = bg
EndIf
GraphicsWindow.PenWidth = 4
GraphicsWindow.DrawLine(x1, y1, x2, y2)
EndSub
Sub DrawMolecularName
GraphicsWindow.FontName = "Trebuchet MS"
GraphicsWindow.BrushColor = "Black"
x = 30
For p = 1 To Text.GetLength(mol)
c = Text.GetSubText(mol, p, 1)
If c = "_" Then
y = 35
p = p + 1
fs = 20
c = Text.GetSubText(mol, p, 1)
Else
y = 20
fs = 30
EndIf
GraphicsWindow.FontSize = fs
GraphicsWindow.DrawText(x, y, c)
x = x + fs * 0.7
EndFor
EndSub
Sub FillCircle
GraphicsWindow.BrushColor = bc
GraphicsWindow.FillEllipse(ox - size / 2, oy - size / 2, size, size)
If opt <> "" Then
GraphicsWindow.FontSize = 35
GraphicsWindow.BrushColor = pc
GraphicsWindow.DrawText(ox + size / 2, oy - size / 2 - 35 * 0.5, opt)
EndIf
EndSub