Function List of the Graphics Library for PowerPoint VBA in World Coordinates

Outline

The argument sequence of the procedure is in a format compliant with N88-BASIC used in an NEC PC-9801 peronal computer. Graphics drawing instructions in world coordinates are defined and libraryized as procedures in standard modules.

Main parameter variables are defined in the declarative part, and values are passed between procedures as global variables.

See VBA Help for Visual Basic constants regarding line styles, color specifications, etc.

Global Variables

 Public gWindowXOrigin As Single, gWindowYOrigin As Single  ' Origin on world coordinates
 Public gFactorX As Single, gFactorY As Single  ' Conversion ratio between world coordinates and screen coordinates
 Public gCurrentX As Single, gCurrentY As Single  ' Current position in world coordinates system
 Public gScreenXLeft As Single, gScreenYTop As Single   ' Upper left coordinates of Viewport
 Public gScreenXRight As Single, gScreenYBottom As Single  ' Lower right coordinates of Viewport
 Public gScreenX As Single, gScreenY As Single  ' Current position in screen coordinates system 
 Public gLineWidth  ' Line width
 Public gLineStyle  ' Line style
 Public gDashStyle  ' Dashed-line style
 Public gLineColor  ' Line color
 Public gAreaColor  ' Fill color
 Public gTextColor  ' Current text color

List of the Sub Procedures

Sub InitializeGraphics()       ' Declaration of using graphics library
Sub SetViewPort(ViewLeft, ViewTop, ViewRight, ViewBottom)       ' Viewport settings
' Specify correspondence between screen coordinates and world coordinates
Sub Move(x, y)Sub SetGraphicsWindow(WindowLeft, WindowTop, WindowRight, WindowBottom)
Sub DrawLineTo(x2, y2, Optional cLineRGB)       ' Draw a line given the end point
Sub DrawLine(x1, y1, x2, y2, Optional cLineRGB)       ' Draw a line given the start and end points
Sub DrawPolyLine(x, y, n)       ' Draw a polyline by connecting multiple points
Sub DrawRectangle(x1, y1, x2, y2, Optional cLineRGB)       ' Draw a rectangle
Sub DrawRectangleFill(x1, y1, x2, y2, Optional cLineRGB, Optional cAreaRGB)    ' Draw a rectangle and fill it inside
Sub DrawOval(x, y, rx, Optional ry, Optional cLineRGB)       ' Draw an ellipse
Sub DrawOvalFill(x, y, rx, Optional ry, Optional cLineRGB, Optional cAreaRGB)     ' Draw a filled ellipse
Sub PointSet(x, y, Optional cLineRGB)       ' Draw a point with a small circle
Sub DrawText(x, y, St, Optional txtcRGB)       ' Display text
Sub SetLineColor(lc)       ' Set the lin color
Sub SetLineStyle(ls)       ' Set the line type
Sub SetDashStyle(ds)       ' Set the Dash line type
Sub SetLineWidth(lw)       ' Set the line thickness
Sub gClear()      ' Erase all objects on the slide
Sub gcls()      ' Erase all objects except controls and placeholders

Features of Graphics Procedures

InitializeGraphics

Initial settings to use the drawing function in world coordinates

  • Using SetViewPort(gScreenXLeft, gScreenYTop, gScreenXRight, gScreenYBottom), Set the drawing range to (0, 0)-(720, 540) for standard slide size. Set the drawing range to (0, 0)-(960, 540) for wide slide size.
  • With SetGraphicsWindow(gScreenXLeft, gScreenYTop, gScreenXRight, gScreenYBottom), the world coordinates remain the same as the screen coordinates and the top left is the origin (0, 0).
  • The line type is set to a thin black solid line.

SetViewPort(ViewLeft, ViewTop, ViewRight, ViewBottom)

Set the viewport(drawable area).

Set the drawing range within the rectangle of screen coordinates (x1, y1)-(x2, y2) using SetViewPort (x1, y1, x2, y2).

SetGraphicsWindow(WindowLeft, WindowTop, WindowRight, WindowBottom)

Specifies the coordinates of the world coordinate system that correspond to the upper left and lower right points of the viewport.

The coordinate system remains the screen coordinates (physical coordinates of the slide).

To use a normal coordinate system whose upper right is positive, specify that the lower left coordinate value is small(negative).

Example  SetGraphicsWindow(-4, 3, 4, -3)

Move(x, y)

Move the current position to (x, y) in the world coordinate system.

DrawLineTo(x2, y2, Optional cLineRGB)

Draw a straight line between the current position and the coordinates (x2, y2) in the world coordinate system. If you do not specify the line color, the current color is used.

DrawLine(x1, y1, x2, y2, Optional cLineRGB)

Draw a straight line between coordinates (x1, y1) and (x2, y2) in the world coordinate system. If you do not specify the line color, the current color is used.

DrawPolyLine(x, y, n)

Draw lines connecting the coordinates specified by the array x, y in the world coordinate system. The current color is used for the line color.

DrawRectangle(x1, y1, x2, y2, Optional cLineRGB)

Draw a rectangle with diagonal points (x1, y1) and (x2, y2) in the world coordinate system. If you do not specify the line color, the current color is used.。

  See  Draw some boxes while changing colors

DrawRectangleFill(x1, y1, x2, y2, Optional cLineRGB, Optional cAreaRGB)

Draw a rectangle with diagonal points (x1, y1) and (x2, y2) in the world coordinate system and fill it inside. If you do not specify the line color, the current color is used. If you do not specify the fill color, it is filled with the same color as the line color.

  See  Draw some boxes while changing colors

DrawOval(x, y, rx, Optional ry, Optional cLineRGB)

Draw an ellipse with a radius rx in the horizontal direction and a radius ry in the vertical direction, centered on the coordinates (x, y) in the world coordinate system. If radius ry is omitted, it means a perfect circle. If you do not specify the line color, the current color is used.

  See  Draw an ellipse

DrawOvalFill(x, y, rx, Optional ry, Optional cLineRGB, Optional cAreaRGB)

Draw an ellipse with a radius rx in the horizontal direction and a radius ry in the vertical direction, centered on the coordinates (x, y) in the world coordinate system and fill it inside. If radius ry is omitted, it means a perfect circle.
If you do not specify the line color, the current color is used. If you do not specify the fill color, it is filled with the same color as the line color.

  See  Draw some circles while changing colors

PointSet(x, y, Optional cLineRGB)

Set point to coordinates (x, y) in the world coordinate system. If you do not specify the color, the current color is used.

Draw a circle of size 1 because VBA has no function to draw points,

DrawText(x, y, St, Optional txtcRGB)

Display the character string St from coordinates (x, y) in the world coordinate system. If you do not specify a color, use the current color of Text

SetLineColor(lc)

Set the line color

SetLineStyle(ls)

Set the line type

  See  Change the line width and type

SetDashStyle(ds)

Set the Dash line type

  See  Change the line width and type

SetLineWidth(lw)

Set the line width

  See  Change the line width and type

gClear

Erases all objects on the slide.

gcls()

Erase all objects except controls s and placeholders on the slide

Cautions

PowerPoint has an undo function. Therefore, drawing a very large number of graphic objects may cause the operation very slow or to hang up.