Microsoft Small Basic

Program Listing: NHB574
' Draw Tartan
' Version 0.1
' Copyright © 2017 Nonki Takahashi. The MIT License.
' Last update 2017-03-15

GraphicsWindow.Title = "Tartan 0.1"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
width = 30
delay = 2000
While "True"
GraphicsWindow.BackgroundColor = GraphicsWindow.GetRandomColor()
DrawTartan()
EndWhile

Sub DrawTartan
' param width - pattern width
' param delay - show duration [ms]
GraphicsWindow.Clear()
color = GraphicsWindow.GetRandomColor()
color = "#80" + Text.GetSubTextToEnd(color, 2)
GraphicsWindow.BrushColor = color
For y = 0 To gh Step width * 2
GraphicsWindow.FillRectangle(0, y, gw, width)
EndFor
For x = 0 To gw Step width * 2
GraphicsWindow.FillRectangle(x, 0, width, gh)
EndFor
color = GraphicsWindow.GetRandomColor()
GraphicsWindow.PenColor = color
For y = width * 1.5 To gh Step width * 2
GraphicsWindow.DrawLine(0, y, gw, y)
EndFor
For x = width * 1.5 To gw Step width * 2
GraphicsWindow.DrawLine(x, 0, x, gh)
EndFor
Program.Delay(delay)
EndSub