Microsoft Small Basic

Program Listing:
Embed this in your website
' Molecular Structure of Ozone
' Version 0.2
' Copyright © 2019 Nonki Takahashi. The MIT License.
' Last update 2019-11-18
' Program ID BVJ146-0

GraphicsWindow.Title = "Molecular Structure of Ozone"
bg = "LightGray"
pc = "DimGray"
GraphicsWindow.BackgroundColor = bg
atom["C"] = "color=Black;size=150;"
atom["O"] = "color=#EE0000;size=100;"
atom["H"] = "color=White;size=50;"
gap = 20
a = 116.8  ' [degree]
gw = GraphicsWindow.Width
gh = GraphicsWindow.Height
mol = "O_3"
DrawMolecularName()
' draw line (1)
x1 = gw / 2
y1 = gh * 0.4
size = atom["O"]["size"]
r = size / 2 + size / 2 + gap
_ah = Math.GetRadians(a / 2)
x2 = x1 - r * Math.Sin(_ah)
y2 = y1 + r * Math.Cos(_ah)
n = 2
DrawLine()
' draw O (1)
ox = x2
oy = y2
bc = atom["O"]["color"]
opt = ""
FillCircle()
' draw line (2)
x2 = x1 + r * Math.Sin(_ah)
n = 1
DrawLine()
' draw O (2)
ox = x2
opt = "-"
FillCircle()
' draw O (3)
ox = x1
oy = y1
opt = "+"
FillCircle()

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, opt)
  EndIf
EndSub
Copyright (c) Microsoft Corporation. All rights reserved.