Microsoft Small Basic

Program Listing: XDW587-0
'Set Image
image = ImageList.LoadImage("http://public.bay.livefilestore.com/y1p6zsS1F5jFqH_wxDAaa4RE5_WsCx_HZ43f1S0Ec98XsEZsGlEO8t0Qo1gj5RNpaNJ9RWBSpelg-sGGgh5kAb24g/bee_icon3.png")
sprite = Shapes.AddImage(image)
imageWidth = ImageList.GetWidthOfImage(image)
imageHeight = ImageList.GetHeightOfImage(image)

'Corners
GraphicsWindow.BrushColor = "Red"
For i = 1 To 4
Shapes.Remove(corner[i])
corner[i] = Shapes.AddEllipse(8,8)
EndFor

'Set bounding box
boundingBox = Shapes.AddRectangle(imageWidth,imageHeight)
Shapes.SetOpacity(boundingBox,50)

'Start keybourd events
GraphicsWindow.KeyDown = OnKeyDown
GraphicsWindow.KeyUp = OnKeyUp

'Initialise varaibles
xPos = 100
yPos = 100
scale = 1
rotate = 0
key = ""

While ("True")
'Get mouse position
xPos = GraphicsWindow.MouseX
yPos = GraphicsWindow.MouseY
'Rotate and scale
If (key = "Right") Then
rotate = rotate+3
ElseIf (key = "Left") Then
rotate = rotate-3
ElseIf (key = "Up") Then
scale = scale+0.1
ElseIf (key = "Down") Then
scale = scale-0.1
EndIf
'Update image
Shapes.Zoom(sprite,scale,scale)
Shapes.Rotate(sprite,rotate)
Shapes.Move(sprite,xPos-imageWidth/2,yPos-imageHeight/2)
'Update bounding box with a shape
Shapes.Zoom(boundingBox,scale,scale)
Shapes.Rotate(boundingBox,rotate)
Shapes.Move(boundingBox,xPos-imageWidth/2,yPos-imageHeight/2)
'Bounding box coordinates - only if you really want them
radius = Math.SquareRoot(imageWidth*imageWidth+imageHeight*imageHeight)/2*scale
coordX[1] = xPos - radius*Math.Cos(Math.GetRadians(rotate-135))
coordY[1] = yPos - radius*Math.Sin(Math.GetRadians(rotate-135))
coordX[2] = xPos - radius*Math.Cos(Math.GetRadians(rotate-45))
coordY[2] = yPos - radius*Math.Sin(Math.GetRadians(rotate-45))
coordX[3] = xPos - radius*Math.Cos(Math.GetRadians(rotate+45))
coordY[3] = yPos - radius*Math.Sin(Math.GetRadians(rotate+45))
coordX[4] = xPos - radius*Math.Cos(Math.GetRadians(rotate+135))
coordY[4] = yPos - radius*Math.Sin(Math.GetRadians(rotate+135))
For i = 1 To 4
Shapes.Move(corner[i],coordX[i]-4,coordY[i]-4)
EndFor
'Delay for smooth running
Program.Delay(100)
EndWhile

Sub OnKeyDown
key = GraphicsWindow.LastKey
EndSub

Sub OnKeyUp
key = ""
EndSub