Microsoft Small Basic

Program Listing: LNM164
' Roulette 0.1a
' Copyright (c) 2013 Nonki Takahashi
'
' History:
' 0.1a 12/06/2013 Created just for picture.
'
GraphicsWindow.Title = "Roulette 0.1a"
gw = GraphicsWindow.Width
gh = GraphicsWindow.Height
csv = "1,5,4,2,6,3"
CSVtoArray()
x0 = gw / 2
y0 = gh / 2
r3 = gh / 2 * 0.8
r2 = r3 * 0.8
r1 = r3 * 0.5
fs = (r3 - r2) * 0.8
GraphicsWindow.BackgroundColor = "Green"
GraphicsWindow.BrushColor = "Black"
GraphicsWindow.FillEllipse(x0 - r3, y0 - r3, r3 * 2, r3 * 2)
GraphicsWindow.BrushColor = "Silver"
GraphicsWindow.FillEllipse(x0 - r2, y0 - r2, r2 * 2, r2 * 2)
GraphicsWindow.PenColor = "Gray"
GraphicsWindow.FontSize = fs
For i = 1 To n
angle = 2 * Math.Pi * i / n
x3 = x0 + r2 * Math.Sin(angle)
y3 = y0 + r2 * Math.Cos(angle)
If Math.Remainder(i, 2) = 0 Then
FillArc()
EndIf
GraphicsWindow.DrawLine(x0, y0, x3, y3)
obj = Shapes.AddText(arry[i])
angle = 2 * Math.Pi * (i + 0.5) / n
x2 = x0 + (r3 + r2) / 2 * Math.Sin(angle)
y2 = y0 + (r3 + r2) / 2 * Math.Cos(angle)
Shapes.Move(obj, x2 - fs * 0.4, y2 - fs * 0.5)
Shapes.Rotate(obj, 180-Math.GetDegrees(angle))
EndFor
GraphicsWindow.BrushColor = "Gray"
GraphicsWindow.FillEllipse(x0 - r1, y0 - r1, r1 * 2, r1 * 2)
GraphicsWindow.BrushColor = "Silver"
GraphicsWindow.PenWidth = 8
GraphicsWindow.PenColor = "Silver"
For i = 1 To 4
angle = 2 * Math.Pi * (i + 0.5) / 4
x1 = x0 + r1 * 0.7 * Math.Sin(angle)
y1 = y0 + r1 * 0.7 * Math.Cos(angle)
GraphicsWindow.FillEllipse(x1 - 8, y1 - 8, 16, 16)
GraphicsWindow.DrawLine(x0, y0, x1, y1)
EndFor
GraphicsWindow.FillEllipse(x0 - 16, y0 - 16, 32, 32)
Sub FillArc
GraphicsWindow.PenColor = "DarkRed"
da = Math.GetRadians(0.32)
For a = angle To angle + 2 * Math.Pi / n - da Step da
x = x0 + r3 * Math.Sin(a)
y = y0 + r3 * Math.Cos(a)
x2 = x0 + r2 * Math.Sin(a)
y2 = y0 + r2 * Math.Cos(a)
GraphicsWindow.DrawLine(x, y, x2, y2)
EndFor
GraphicsWindow.PenColor = "Gray"
EndSub
Sub CSVtoArray
n = 0
p = 1
l = Text.GetLength(csv)
While p <= l
_p = Text.GetIndexOf(Text.GetSubTextToEnd(csv, p), ",")
If 0 < _p Then
n = n + 1
arry[n] = Text.GetSubText(csv, p, _p - 1)
p = p + _p
Else
n = n + 1
arry[n] = Text.GetSubTextToEnd(csv, p)
p = l + 1
EndIf
EndWhile
EndSub