Function List of the Turtle Graphics Library for Excel VBA
using GDI32 Instructions
Outline
We defined the functionality of Turtle graphics as VBA procedures. The format of the turtle graphics instruction has been made similar to the LOGO instruction.
We expect to be used in programming education for beginners.
Global Variables
Public gTGAngle As Variant Public gTGCurrentX, gTGCurrentY ' Current position Public Const gDeg2Rad = 3.14159265358979 / 180#
List of the Sub Procedures
Sub InitializeTurtleGraphics() ' Initial settings Sub TGMove(length) ' Move by specified length Sub TGMoveL(length, Optional cRGBLine) ' Draw a straight line of specified length Sub TGSetPoint(x0, y0) ' Set the current position Sub TGSetAngle(a0) ' Set to specified angle Sub TGTurn(a) ' Turn left Sub TGRightTurn(a) ' Turn right Sub TGLeftTurn(a) ' Turn left Sub TGBackward(length) ' Move backward by specified length Sub TGBackwardL(length, Optional cRGBLine) ' Draw a line in the reverse direction Sub SetLineColor(c) ' Set the line color Sub SetLineWidth(lw) ' Set the line thickness Sub gClear(Optional bc) ' Fill the viewport area with the specified color
Features of Turtle Graphics Procedures
InitializeTurtleGraphics
Initial settings to use the turtle graphics drawing function
- Set the drawing range to (0, 0)-(639, 479).
- Set the turtle at the bottom center of the drawing area. Set the turtle's direction upward(north).
- The line type is set to a thin black solid line.
TGMove(length)
Advances the turtle in the current direction by the value of length. If the value is negative, it moves backwards.
TGMoveL(length, Optional cRGBLine)
Advances the turtle in the current direction by the value of length and draw a trajectory. If the value is negative, it moves backwards.
If you do not specify the line color, the current color is used.
TGSetPoint(x0, y0)
Set the turtle to the specified position (x0, y0).
TGTurn(a)
Rotate the turtle counterclockwise by the value of angle a. If the value is negative, it will rotate clockwise.
Same as TGLeftTurn(a).
TGSetAngle(a0)
Set the turtle's orientation to the value of angle a. The upward (north) direction is 0 degrees.
TGRightTurn(a)
Rotate the turtle clockwise by the value of angle a. If the value is negative, it will rotate counterclockwise.
TGLeftTurn(a)
Rotate the turtle counterclockwise by the value of angle a. If the value is negative, it will rotate clockwise.
TGBackward(length)
Advances the turtle in the reverse direction by the value of length.
TGBackwardL(length, Optional cRGBLine)
Advances the turtle in the reverse direction by the value of length and draw a trajectory. If you do not specify the line color, the current color is used.
TGBackwardL(length, Optional cRGBLine)
Advances the turtle in the reverse direction by the value of length and draw a trajectory. If you do not specify the line color, the current color is used.
SetLineColor(c)
Specify the line color using RGB color.
SetLineWidth(lw)
Specify line width in pixels.
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. i.e. RGB(240, 240, 240).