Computer Studies‎ > ‎Turing‎ > ‎Turing References‎ > ‎

Turing Graphics Commands

The following summary is taken from the Turing Help file. See this file for many excellent examples. See also Turing Graphics - Screen Coordinates.

cls
  • The cls (clear screen) procedure is used to blank the output window. The cursor is set to the top left (to row 1, column 1).
  • The entire output window is set to the current text background color (as set by colorback or Text.ColorBack).
colour (Color : int)
  • The color procedure is used to change the currently active color. This is the color of characters that are to be put on the screen. The alternate spelling is colour.
  • See maxcolor for the number of colors available in the various "graphics" modes. The background color that text appears upon can be set using the colorback procedure.
colorback (Color : int)
  • The colorback procedure is used to change the color upon which text appears. The alternate spelling is colourback.
drawarc (x, y, xRadius, yRadius : int, initialAngle, finalAngle, Color : int) 
  • The drawarc procedure is used to draw an arc whose center is at (x, y). This is just like drawoval, except that you must also give two angles, initialAngle and finalAngle, which determine where to start and stop drawing. Zero degrees is "three o'clock", 90 degrees is "twelve o'clock", etc. The horizontal and vertical distances from the center to the arc are given by xRadius and yRadius.
drawbox (x1, y1, x2, y2, Color : int)
  • The drawbox procedure is used to draw a box on the screen with bottom left and top right corners of (x1, y1) to (x2, y2) using the specified Color.
drawdot (x, y, Color : int)
  • The drawdot procedure is used to color the dot (pixel) at location (x, y) using the specified Color.
drawfill (x, y : int, fillColor, borderColor : int)
  • The drawfill procedure is used to color in a figure that is on the screen. Starting at (x, y), the figure is filled with fillColor to a surrounding border whose color is borderColor.
drawfillarc (x, y, xRadius, yRadius : int, initialAngle, finalAngle, Color : int)
  • The drawfillarc procedure is used to draw a filled arc whose center is at (x, y). It then fills in the pie-shaped wedge using the specified Color. To outline a filled arc, use drawfillarc with the Color parameter set to the fill color and then drawarc with the Color parameter set to the border color. For initialAngle and finalAngle, which determine the edges of the wedge, zero degrees is "three o'clock" and 90 degrees is "twelve o'clock", etc. The horizontal and vertical distances from the center to the arc are given by xRadius and yRadius.
drawfillbox (x1, y1, x2, y2, Color : int)
  • The drawfillbox procedure is used to draw a filled box on the screen with bottom left and top right corners of (x1, y1) to (x2, y2) filled using the specified Color. To get a box outlined in a different color, use drawfillbox with the Color parameter set to the fill color and then call drawbox with the Color parameter set to the border color.
drawfillmapleleaf (x1, y1, x2, y2, Color : int)
  • The drawfillmapleleaf procedure is used to draw a filled maple leaf on the screen bounded by a rectangle with bottom left and top right corners of (x1, y1) to (x2, y2) and filled using the specified Color. To get a maple leaf outlined in a different color, use drawfillmapleleaf with the Color parameter set to the fill color and then call drawmapleleaf with the Color parameter set to the border color. If y1 is greater than y2, then the maple leaf is drawn upside down.
drawfilloval (x, y, xRadius, yRadius, Color : int)
  • The drawfilloval procedure is used to draw a filled oval whose center is at (x, y). The horizontal and vertical distances from the center to the oval are given by xRadius and yRadius. To get an oval outlined in a different color, use drawfilloval with the Color parameter set to the fill color and then call drawoval with the Color parameter set to the border color.
drawfillpolygon (x, y : array 1 .. * of int, n : int, Color : int)
  • The drawfillpolygon procedure is used to draw a filled polygon with n points. The polygon is described by the points (x(1), y(1)) to (x(2), y(2)) to (x(3), y(3)) and so on to (x(n), y (n)). The polygon will be drawn and filled with Color. 
  • To get an polygon outlined in a different color, use drawfillpolygon with the Color parameter set to the fill color and then call drawpolygon with the Color parameter set to the border color.
drawfillstar (x1, y1, x2, y2, Color : int)
  • The drawfillstar procedure is used to draw a filled five pointed star on the screen bounded by a rectangle with bottom left and top right corners of (x1, y1) to (x2, y2) and filled using the specified Color. To get a star outlined in a different color, use drawfillstar with the Color parameter set to the fill color and then call drawstar with the Color parameter set to the border color. If y1 is greater than y2, then the star is drawn upside down.
drawline (x1, y1, x2, y2, Color : int)
  • The drawline procedure is used to draw a line on the screen from (x1, y1) to (x2, y2) using the specified Color.
drawmapleleaf (x1, y1, x2, y2, Color : int)
  • The drawmapleleaf procedure is used to draw a maple leaf on the screen bounded by a rectangle described by the bottom left and top right corners of (x1, y1) to (x2, y2) using the specified Color. If y1 is greater than y2, then the maple leaf is drawn upside down.
drawoval (x, y, xRadius, yRadius, Color : int)
  • The drawoval procedure is used to draw an oval whose center is at (x, y). The horizontal and vertical distances from the center to the oval are given by xRadius and yRadius.
drawpic (x, y : int, buffer : array 1 .. * of int, picmode : int)
  • The drawpic procedure is used to copy of a rectangular picture onto the screen. The left bottom of the picture is placed at (x, y). In the common case, the buffer was initialized by calling takepic. The values of picmode are:
    •  0: Copy actual picture on screen. 
    •  1: Copy picture by XORing it onto the screen. 
  • XORing a picture onto the screen twice leaves the screen as it was (this is a convenient way to move images for animation). XORing a picture onto a background effectively superimposes the picture onto the background.
drawpolygon (x, y : array 1 .. * of int, n : int, Color : int)
  • The drawpolygon procedure is used to draw a polygon with n points. A line is drawn in Color from the point (x(1), y(1)) to (x(2), y(2)) to (x(3), y(3)) and so on. After drawing the line to (x(n), y (n)), a line will be drawn back to (x(1), y(1)), closing the polygon. The drawpolygon procedure is equivalent to:
for i : 1 .. n - 1
drawline (x (i), y(i), x (i + 1), y (i + 1), Color)
end for
drawline (x (n), y (n), x (1), y (1), Color)
  • Note: The IBM PC limits drawpolygon to a maximum of 256 points.
drawstar (x1, y1, x2, y2, Color : int)
  • The drawstar procedure is used to draw a star on the screen bounded by a rectangle described by the bottom left and top right corners of (x1, y1) to (x2, y2) using the specified Color. If y1 is greater than y2, then the star is drawn upside down.
locate ( row, column : int )
  • The locate procedure is used to move the cursor so that the next output from put will be at the given row and column. Row 1 is the top of the screen and column 1 is the left side of the screen.
  • See also the locatexy procedure which is used to locate the output based x and y positions, where x=0, y=0 is the left bottom of the screen.
locatexy ( x , y : int )
  • The locatexy procedure is used to move the cursor so that the next output from put will be at approximately (x, y). The exact location may be somewhat to the left of x and below y to force alignment to a character boundary.
maxcol : int
  • The maxcol function is used to determine the number of columns on the screen.
maxcolor : int
  • The maxcolor function is used to determine the maximum color number for the current mode of the screen. The alternate spelling is maxcolour.
maxrow : int
  • The maxrow function is used to determine the number of rows on the screen.
maxx : int
  • The maxx function is used to determine the maximum value of x for the current graphics mode.
maxy : int
  • The maxy function is used to determine the maximum value of y for the current graphics mode.
setscreen ( s : string )
  • Here are example uses of the setscreen procedure. In many cases, these will appear as the first statement of the program. They can, however, appear any place in a program.
setscreen ( "graphics" )            % Enter graphics mode
setscreen ( "graphics:400;300" )    % Change window to 400x300
setscreen ( "nocursor" )            % Turn off cursor
setscreen ( "noecho" )              % Do not echo keys
  • The setscreen statement is used to change the mode of the screen, as well as the way in which Turing does input and output. The parameter to setscreen is a string, such as "graphics". The string contains one or more options separated by commas, such as "text, noecho".
sizepic ( x1, y1, x2, y2 : int) : int
  • The sizepic function is used to determine the size buffer needed to record a picture from the screen (see description of takepic ). This gives the minimum number of elements of the int array used by takepic. The buffer is used by drawpic to make  copies of the picture on the screen.
takepic (x1, y1, x2, y2 : int, var buffer : array 1 .. * of int)
  • The takepic procedure is used to record the pixel values in a rectangle, with left bottom and right corners of (x1, y1) and (x2, y2), in the buffer array. This requires a sufficiently-large buffer (see sizepic ). The drawpic procedure is used to make copies of the recorded rectangle on the screen.
whatcol : int
  • The whatcol function is used to determine the cursor position's column.
whatcolor : int
  • The whatcolor function is used to determine the current (foreground) color, ie., the color used for characters that are output using put. The alternate spelling is whatcolour.
whatcolorback : int
  • The whatcolorback function is used to determine the current background color. The alternate spelling is whatcolourback.
whatdotcolor ( x, y : int ) : int
  • The whatdotcolor function is used to determine the color number of the specified pixel. The alternate spelling is whatdotcolour.
whatrow : int
  • The whatrow function is used to determine the cursor position's row.

Comments