Microsoft Small Basic

Program Listing: DZC358-1
' Rainbow 0.2
' Copyright (c) 2012, 2013 Nonki Takahashi. All rights reserved.
'
' History:
' 0.2 2013/02/13 Rewrote. (DZC358-0)
' 0.1 2012/06/06 Created. (DZC358)
title = "Rainbow 0.2"
width = 600
height = 400
GraphicsWindow.Title = title
GraphicsWindow.Width = width
GraphicsWindow.Height = height
GraphicsWindow.BackgroundColor = "DimGray"
GraphicsWindow.PenWidth = 1
x0 = width / 2
y0 = height - 50
r = width / 2
For dr = 0 To 19
hue = dr * 18
HueToColor()
clr[dr] = color
EndFor
ChangePicture()
For angle = 0 To 180 Step 2
For dr = 0 To 19
hue = dr * 18
HueToColor()
GraphicsWindow.PenColor = clr[dr]
x2[dr] = (r - dr) * Math.Cos(Math.GetRadians(angle)) + x0
y2[dr] = -(r - dr) * Math.Sin(Math.GetRadians(angle)) + y0
If angle > 10 Then
line = Shapes.AddLine(x1[dr], y1[dr], x2[dr], y2[dr])
Shapes.SetOpacity(line, (90 - Math.Abs(angle - 90)) / 90 * 50)
EndIf
x1[dr] = x2[dr]
y1[dr] = y2[dr]
EndFor
EndFor
next = "False"
'GraphicsWindow.MouseDown = OnMouseDown
Timer.Interval = 3000
Timer.Tick = OnTick
While "True"
Program.Delay(200)
If next Then
ChangePicture()
next = "False"
EndIf
EndWhile
Sub OnMouseDown
next = "True"
EndSub
Sub OnTick
next = "True"
EndSub
Sub ChangePicture
tag = "cloud"
url = Flickr.GetRandomPicture(tag)
GraphicsWindow.DrawResizedImage(url, 0, 0, width, height)
EndSub
Sub HueToColor
' param hue - 0..360
' return color
If hue < 0 Then
red = 0
green = 0
blue = 0
ElseIf hue < 60 Then
red = 255
green = Math.Floor(hue / 59 * 255)
blue = 0
ElseIf hue < 120 Then
red = Math.Floor((59 - (hue - 60)) / 59 * 255)
green = 255
blue = 0
ElseIf hue < 180 Then
red = 0
green = 255
blue = Math.Floor((hue - 120) / 59 * 255)
ElseIf hue < 240 Then
red = 0
green = Math.Floor((59 - (hue - 180)) / 59 * 255)
blue = 255
ElseIf hue < 300 Then
red = Math.Floor((hue - 240) / 59 * 255)
green = 0
blue = 255
ElseIf hue < 360 Then
red = 255
green = 0
blue = Math.Floor((59 - (hue - 300)) / 59 * 255)
Else
red = 0
green = 0
blue = 0
EndIf
red = red / 2 + 128
green = green / 2 + 128
blue = blue / 2 + 128
color = GraphicsWindow.GetColorFromRGB(red, green, blue)
EndSub