Microsoft Small Basic

Program Listing: NFR093
' Slide Effect
' Copyright © 2017 Nonki Takahashi. The MIT License.

title = "Slide Effect"
GraphicsWindow.Title = title
Init()
While "True"
i = i + 1
If 30 < i Then
i = 1
EndIf
dup = "True"
While dup
dup = "False"
url[i] = Flickr.GetRandomPicture("toy")
For j = 1 To Array.GetItemCount(url)
If (i <> j) And (url [i] = url[j]) Then
dup = "True"
j = Array.GetItemCount(url) ' exit For
EndIf
EndFor
EndWhile
img = ImageList.LoadImage(url[i])
iw = ImageList.GetWidthOfImage(img)
ih = ImageList.GetHeightOfImage(img)
shp1 = shp
shp = Shapes.AddImage(img)
If (ih / iw) < (gh / gw) Then
' flat image
width = gh / iw * ih
height = gh
Shapes.Zoom(shp, gh / ih, gh / ih)
Else
' tall image
width = gw
height = gw / ih * iw
Shapes.Zoom(shp, gw / iw, gw / iw)
EndIf
x1 = gw + (width + iw) / 2
x2 = (gw - iw) / 2
y = (gh - ih) / 2
Shapes.Move(shp, x1, y)
GraphicsWindow.Title = title + " - " + url[i]
For k = 0 To 1 Step 1 / n
x = x1 * (1 - k) + x2 * k
Shapes.Move(shp, x, y)
Program.Delay(delay / n)
EndFor
Shapes.Remove(shp1)
Program.Delay(1000)
EndWhile

Sub Init
gw = 598
gh = 428
size = 800
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
xo = gw / 2
yo = gh / 2
root2 = Math.SquareRoot(2)
delay = 1000
GraphicsWindow.PenWidth = 2
GraphicsWindow.BackgroundColor = "Black"
n = 40
i = 0
EndSub