Function List of the Graphics Library for PowerPoint VBA
using GDI32 Instructions
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 gLineColor ' Line color Public gAreaColor ' Fill 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 SetLineWidth(lw) ' Set the line thickness Sub gClear() ' Fill the viewport area with the specified color Sub gcls(x1, y1, x2, y2, Optional bc) ' Fill thespecified area with the specified color
Features of Graphics Procedures
InitializeGraphics
Initial settings to use the drawing function in world coordinates
- Set the drawing range to (0, 0)-(640, 480) using SetViewPort (0, 0, 640, 480).
- With SetGraphicsWindow (0, 0, 640, 480), 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) because SetViewPort (0, 0, 640, 480); SetGraphics Window (0, 0, 640, 480) is initially used.
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 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.
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.
The upper limit on the number of points is 10,001. If you want to use more points, change the declaration of the array.
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.。
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.
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.
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.
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 when the linewidth is less than or equal to 1
SetLineWidth(lw)
Set the line width
gClear(Optional bc)
Fill the viewport area with the specified color. If you do not specify a color, the default background color of Form is used. RGB (240, 240, 240)
gcls(x1, y1, x2, y2, Optional bc)
Fill the specified area with the specified color. If you do not specify a color, the default background color of Form is used. RGB (240, 240, 240)
Notice
Before calling InitializeGraphics , obtain the device context and assign it to the public variable myhdc. p>
monhdc = GetForegroundWindow() myhdc = GetDC(monhdc)