Microsoft Small Basic

Program Listing: GGK772-0
GraphicsWindow.Title = "100lines Guru Medals"
GraphicsWindow.BackgroundColor="Teal
colors = "1=Gold;2=Silver;3=#AC6B25;" ' bronze
di = 222 ' diameter
gw = 800
gh = 528
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BrushColor = "Black"
tbox = Controls.AddTextBox(10, 10)
Controls.SetTextBoxText(tbox, di)
Controls.SetSize(tbox, 50, 22)
Controls.AddButton("Draw", 72, 8)
GraphicsWindow.FontName = "Trebuchet MS"
DrawMedals()
' initialize shapes

Controls.ButtonClicked = OnButtonClicked
While "True"
If buttonClicked Then
di = Controls.GetTextBoxText(tbox)
DrawMedals()
scale = di / 200

x = 30 + (4 - 1) * (di + 20)
y = 50

buttonClicked = "False"
Else
Program.Delay(1)
EndIf
EndWhile
Sub OnButtonClicked
buttonClicked = "True"
EndSub
Sub DrawMedals
GraphicsWindow.BrushColor ="teal
gw = GraphicsWindow.Width
gh = GraphicsWindow.Height
GraphicsWindow.FillRectangle(0, 0, gw, gh)
GraphicsWindow.FontSize = 20 * di / 100
th = 8 * di / 100
For i = 1 To 3
x0 = 30 + (i - 1) * (di + 20)
y0 = 50
GraphicsWindow.BrushColor = colors[i]
color = GraphicsWindow.BrushColor
GraphicsWindow.FillTriangle(x0+di/2,y0,x0-50+di/2,y0+400,x0+di/2,y0+350)
GraphicsWindow.FillTriangle(x0+di/2,y0,x0+50+di/2,y0+400,x0+di/2,y0+350)

lsave = LDColours.GetLightness(color)
ra = (di - 1) / 2 ' radius
x1 = x0 + ra
y1 = y0 + ra
For a = 0 To 360 Step 2
_a = Math.GetRadians(a)
x3 = x1 + ra * Math.Sin(_a)
y3 = y1 - ra * Math.Cos(_a)
If 0 < a Then
GraphicsWindow.FillTriangle(x1, y1, x2, y2, x3, y3)
If 90 < a And a < 270 Then
lightness = Math.Abs(lightness - 0.2)
color=LDColours.HSLtoRGB (LDColours.GetHue(color), LDColours.GetSaturation (color), lightness )
GraphicsWindow.BrushColor = color
GraphicsWindow.FillTriangle(x2, y2, x3, y3, x2, y2 + th)
GraphicsWindow.FillTriangle(x3, y3, x2, y2 + th, x3, y3 + th)
EndIf
EndIf
n = 3
lightness = lsave - (Math.Abs(Math.Remainder(_a + Math.Pi / 4, Math.Pi / n) - Math.Pi / (n * 2)) / (Math.Pi / 2)) * lsave
color=LDColours.HSLtoRGB (LDColours.GetHue(color), LDColours.GetSaturation (color), lightness )

GraphicsWindow.BrushColor = color
_a = Math.GetRadians(a - 2)
x2 = x1 + ra * Math.Sin(_a)
y2 = y1 - ra * Math.Cos(_a)
EndFor
GraphicsWindow.BrushColor = colors[i]
color = GraphicsWindow.BrushColor

'Color_RGBtoHSL()
lightness = lsave * 0.2
color=LDColours.HSLtoRGB (LDColours.GetHue(color), LDColours.GetSaturation (color), lightness )

GraphicsWindow.BrushColor = color
GraphicsWindow.DrawText(x0 +17* di / 100-13, y0 + 27 * di / 100, "100lines")
GraphicsWindow.DrawText(x0 + 26 * di / 100-13, y0 + 47 * di / 100, "Guru")
lightness = lsave * 0.8
color=LDColours.HSLtoRGB (LDColours.GetHue(color), LDColours.GetSaturation (color), lightness )

GraphicsWindow.BrushColor = color
GraphicsWindow.DrawText(x0 + 17 * di / 100-13, y0 + 28 * di / 100, "100lines")
GraphicsWindow.DrawText(x0 + 27 * di / 100-13, y0 + 48 * di / 100, "Guru")
EndFor
EndSub