Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The Microsoft Small Basic Shapes object allows you to do the following with shapes in the graphics window, as demonstrated in the following code:
- Add shapes such as ellipses, images, lines, rectangles, and trianges. These shapes can be animated, moved, rotated, and zoomed.
- Get the screen coordinates of existing shapes.
- Hide and redisplay existing shapes.
- Get and change the opacity ("see-throughness") of an existing shape.
ellipse = Shapes.AddEllipse(50, 30)
image = Shapes.AddImage(Flickr.GetRandomPicture("cat"))
' Pause the program after each action so that you can see what's happening.
PauseProgram()
Shapes.Move(image, 200, 300)
PauseProgram()
line = Shapes.AddLine(0, 100, 20, 120)
PauseProgram()
rectangle = Shapes.AddRectangle(50, 30)
PauseProgram()
triangle = Shapes.AddTriangle(0, 0, 0, 30, 30, 0)
PauseProgram()
Shapes.Animate(ellipse, 100, 100, 2000)
PauseProgram()
GraphicsWindow.Title = "line's left is: " + Shapes.GetLeft(line)
PauseProgram()
GraphicsWindow.Title = "ellipse's top is: " + Shapes.GetTop(ellipse)
PauseProgram()
Shapes.HideShape(triangle)
PauseProgram()
Shapes.Move(rectangle, 100, 10)
PauseProgram()
Shapes.Remove(line)
PauseProgram()
Shapes.Rotate(rectangle, 45)
PauseProgram()
Shapes.SetOpacity(rectangle, 50)
PauseProgram()
Shapes.ShowShape(triangle)
PauseProgram()
Shapes.Zoom(ellipse, 3, 5)
GraphicsWindow.ShowMessage("Done!", "Done")
Sub PauseProgram
' Pause the program for 2 seconds (2000 milleseconds).
Program.Delay(2000)
EndSub