Microsoft Small Basic

Program Listing: PKD200
' Sample Code for Flickr Object

WQ = Text.GetCharacter(34)
Init()
While "True"
caption = "Flickr.GetPictureOfMoment()"
url = Flickr.GetPictureOfMoment()
ShowPicture()
Program.Delay(10000)
caption = "Flickr.GetRandomPicture(" + WQ + "toy" + WQ + ")"
url = Flickr.GetRandomPicture("toy")
ShowPicture()
Program.Delay(10000)
EndWhile

Sub Init
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.BackgroundColor = "#333333"
EndSub

Sub ShowPicture
' param caption - to show
' param url - image url
img = ImageList.LoadImage(url)
GraphicsWindow.Clear()
width = ImageList.GetWidthOfImage(img)
height = ImageList.GetHeightOfImage(img)
GraphicsWindow.Title = caption + " | " + width + "×" + height
If gw / gh < width / height Then
width = gw ' adjust width
height = height / width * gw
Else
height = gh ' adjust height
width = width / height * gh
EndIf
x = (gw - width) / 2
y = (gh - height) / 2
GraphicsWindow.DrawResizedImage(img, x, y, width, height)
EndSub