Microsoft Small Basic

Program Listing: GWD549
' Toy Poodle
' Version 0.1
' Copyright © 2017 Nonki Takahashi. The MIT License.

GraphicsWindow.Title = "Toy Poodle"
debug = "False"
param = "x=200;y=200;width=250;height=100;"
FillCurlyRectangle()
param = "x=450;y=200;width=60;height=20;"
FillCurlyRectangle()
param = "x=200;y=300;width=20;height=100;"
FillCurlyRectangle()
param = "x=240;y=300;width=20;height=100;"
FillCurlyRectangle()
param = "x=390;y=300;width=20;height=100;"
FillCurlyRectangle()
param = "x=430;y=300;width=20;height=100;"
FillCurlyRectangle()
param = "x=150;y=100;width=100;height=120;"
FillCurlyEllipse()
param = "x=130;y=110;width=50;height=60;"
FillCurlyRectangle()
param = "x=220;y=110;width=50;height=60;"
FillCurlyRectangle()
GraphicsWindow.PenWidth = 1
GraphicsWindow.PenColor = "#FFFFFF"
GraphicsWindow.BrushColor = "#000000"
GraphicsWindow.FillEllipse(160, 150, 20, 20)
GraphicsWindow.DrawEllipse(160, 150, 20, 20)
GraphicsWindow.FillEllipse(210, 150, 20, 20)
GraphicsWindow.DrawEllipse(210, 150, 20, 20)
GraphicsWindow.PenColor = "#333333"
GraphicsWindow.FillEllipse(180, 180, 20, 15)
GraphicsWindow.DrawEllipse(180, 180, 20, 15)

Sub GetParam
x = param["x"]
y = param["y"]
width = param["width"]
height = param["height"]
EndSub

Sub FillCurlyEllipse
' param x, y - left top corner
' param width, height - size
GetParam()
GraphicsWindow.BrushColor = "#111111"
GraphicsWindow.FillEllipse(x, y, width, height)
If debug Then
Goto fce_exit
EndIf
For i = 1 To (width * height) / (5 * 5)
rx = Math.GetRandomNumber(width / 2)
ry = Math.GetRandomNumber(height / 2)
a = Math.GetRandomNumber(360)
_a = Math.GetRadians(a)
cx = x + width / 2 + rx * Math.Cos(_a)
cy = y + height / 2 + ry * Math.Sin(_a)
DrawCurly()
EndFor
fce_exit:
EndSub

Sub FillCurlyRectangle
' param x, y - left top corner
' param width, height - size
GetParam()
GraphicsWindow.BrushColor = "#111111"
GraphicsWindow.FillRectangle(x, y, width, height)
If debug Then
Goto fcr_exit
EndIf
For i = 1 To (width * height) / (5 * 5)
cx = x + Math.GetRandomNumber(width)
cy = y + Math.GetRandomNumber(height)
DrawCurly()
EndFor
fcr_exit:
EndSub

Sub DrawCurly
r = 5
dr = 5 / (360 / 10)
a0 = Math.GetRandomNumber(360)
For a = 0 To 360 Step 10
_a = Math.GetRadians(a + a0)
cx = cx + r * a / 360 * Math.Cos(_a)
cy = cy + r * a / 360 * Math.Sin(_a)
_x = cx - r / 2
_y = cy - r / 2
l = (360 - a) / 3
GetColors()
GraphicsWindow.BrushColor = gray
GraphicsWindow.FillEllipse(_x, _y, 2*r, 2*r)
GraphicsWindow.BrushColor = black
GraphicsWindow.FillEllipse(_x + 1, _y + 1, 2*r, 2*r)
r = r - dr
EndFor
EndSub

Sub GetColors
α = (120 - l) * 255 / 120
dec = α
Math_Dec2Hex()
black = "#" + hex + "000000"
gray = "#" + hex + "222222"
EndSub

Sub Math_Dec2Hex
' Math | Convert decimal to hexadecimal
' param dec
' param hex
Stack.PushValue("math", dec)
hex = ""
While dec > 0
mod = Math.Remainder(dec, 16)
hex = Text.Append(Text.GetSubText("0123456789ABCDEF", mod + 1, 1), hex)
dec = Math.Floor(dec / 16)
EndWhile
If Text.GetLength(hex) = 0 Then
hex = "00"
ElseIf Text.GetLength(hex) = 1 Then
hex = Text.Append("0", hex)
EndIf
dec = Stack.PopValue("math")
EndSub