Microsoft Small Basic

Program Listing: JTH842-0
' Geometric Pattern #02
' Copyright (c) 2014 Nonki Takahashi.
'
' Lisence:
' The MIT Lisence (MIT)
' http://en.wikipedia.org/wiki/MIT_License
'
' History:
' #02 2014-05-13 Pattern changed. (JTH842-0)
' #01 2014-05-01 Created. (JTH842)
'
GraphicsWindow.Title = "Geometric Pattern #02"
Not = "False=True;True=False;"
gw = 598
gh = 428
bg = "Lime"
color = "1=Green;2=LimeGreen;"
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = bg
w = 60
h = w * 2 / Math.SquareRoot(3)
odd = "True"
For y = -h / 4 To gh Step h * 3 / 4
If odd Then
x0 = 0
Else
x0 = -w / 2
EndIf
For x = x0 To gw Step w
DrawPattern()
EndFor
odd = Not[odd]
EndFor
Sub DrawPattern
' param x
' param y
' param size
GraphicsWindow.BrushColor = color[1]
GraphicsWindow.FillTriangle(x, y + h / 4, x, y + h / 2, x + w / 2, y + h / 2)
GraphicsWindow.FillRectangle(x, y + h / 2, w / 2, h / 4 + 1.5)
GraphicsWindow.FillTriangle(x, y + h * 3 / 4, x + w / 2, y + h * 3 / 4, x + w / 2, y + h)
GraphicsWindow.BrushColor = color[2]
GraphicsWindow.FillTriangle(x + w / 2, y + h / 2, x + w, y + h / 4, x + w, y + h / 2)
GraphicsWindow.FillRectangle(x + w / 2, y + h / 2, w / 2, h / 4 + 1.5)
GraphicsWindow.FillTriangle(x + w / 2, y + h * 3 / 4, x + w / 2, y + h, x + w, y + h * 3 / 4)
EndSub