Microsoft Small Basic

Program Listing: BQX534
' Hydrangea
' Copyright (c) 2014 Nonki Takahashi. The MIT License.
'
GraphicsWindow.Title = "Hydrangea"
GraphicsWindow.BackgroundColor = "SeaGreen"
param = "size=40;color=DarkSeaGreen;x=75;y=60;"
AddInflorescence()
param = "size=40;color=Pink;x=100;y=200;"
AddInflorescence()
param = "size=40;color=PaleTurquoise;x=300;y=40;"
AddInflorescence()
param = "size=40;color=White;x=425;y=160;"
AddInflorescence()
param = "size=40;color=Lavender;x=275;y=260;"
AddInflorescence()
Sub AddInflorescence
size = param["size"]
color = param["color"]
cy = param["y"]
Stack.PushValue("local", size)
size = size * 0.8
stp = size * 1.25
For cx = param["x"] + stp + 20 To param["x"] + stp * 2 + 20 Step stp
angle = Math.GetRandomNumber(360)
AddHydrangea()
EndFor
cy = cy + size
size = Stack.PopValue("local")
stp = size * 1.25
For cx = param["x"] + stp - 25 To param["x"] + stp * 3 - 25 Step stp
angle = Math.GetRandomNumber(360)
AddHydrangea()
EndFor
cy = cy + size
For cx = param["x"] To param["x"] + stp * 3 Step stp
angle = Math.GetRandomNumber(360)
AddHydrangea()
EndFor
cy = cy + size
For cx = param["x"] + stp - 25 To param["x"] + stp * 3 - 25 Step stp
angle = Math.GetRandomNumber(360)
AddHydrangea()
EndFor
EndSub
Sub AddHydrangea
' param color - color of hydrangea
' param angle - angle of hydrangea
' param size - size of hydrangea
' param cx, cy - center co-ordinate
GraphicsWindow.BrushColor = color
Stack.PushValue("local", angle)
For i = 1 To 4
GraphicsWindow.PenWidth = 0
calyx = Shapes.AddRectangle(size * 0.44, size * 0.44)
Shapes.Rotate(calyx, angle)
angle = angle + 45
If 360 <= angle Then
angle = angle - 360
EndIf
_angle = Math.GetRadians(angle)
root2 = Math.SquareRoot(2)
x = cx + (size * 0.30 * root2) * Math.Cos(_angle)
y = cy + (size * 0.30 * root2) * Math.Sin(_angle)
Shapes.Move(calyx, x - size * 0.22, y - size * 0.22)
'GraphicsWindow.PenWidth = 1
flower = Shapes.AddEllipse(size * 0.12, size * 0.12)
angle = angle + 45
If 360 <= angle Then
angle = angle - 360
EndIf
_angle = Math.GetRadians(angle)
x = cx + (size * 0.08 * root2) * Math.Cos(_angle)
y = cy + (size * 0.08 * root2) * Math.Sin(_angle)
Shapes.Move(flower, x - size * 0.06, y - size * 0.06)
EndFor
angle = Stack.PopValue("local")
EndSub