For any graphics, the first important lesson is that the pen must be in the DOWN position for graphics to display on the screen. The default is UP, so remember to issue the DOWN command to start drawing.
print #1, "down" 'put the pen down
print #1, "up" 'raise the pen, no graphics will be drawn
SIZE
By default, the drawing pen is a single pixel wide. It can be made any size with the SIZE comand. Remember that objects drawn with a larger-sized pen will take up more space than objects drawn with the default 1-pixel-wide pen. To issue the size command:
print #1, "size 10" 'a pen 10 pixels wide
'using variables:
s = 10
print #1, "size ";s
Remember that variables must be placed outside of the quote marks and that blank spaces must be preserved.
FILL and CLS
The FILL command causes the graphicbox or graphics window to be filled with the designated color. This will cover any existing graphics. FILL can be a named Liberty BASIC color, or an RGB color. For more, see ColorInGraphics. To clear the screen and erase drawn objects from memory, issue a CLS command.
Objects are drawn with a pen in the COLOR chosen. The default color is black. To change the color at any time in a program, issue a COLOR command. Objects will be drawn in that color until another COLOR command is issued. The color can be a named Liberty BASIC color, or an RGB color. For more, see ColorsInGraphics Examples of the COLOR command:
Objects can be drawn as outlines, or as objects filled with a color. Filled objects are filled with the current BACKCOLOR. The default BACKCOLOR is white. For more, see ColorInGraphics. BACKCOLOR can be a named Liberty BASIC color, or an RGB color. It will be used to fill drawn objects until another BACKCOLOR command is issued. Examples of the BACKCOLOR command.
The pen starts at point 0, 0. This is the upper left corner of the graphics area. The x values get larger as you move right and the y values get larger as you move down. You can locate the pen using turtle graphics commands. See TurtleGraphics It is more common to locate the pen using the PLACE command when drawing objects. This command puts the drawing pen at the x,y location given. The pen does not draw a line from its previous position. It is lifted and placed at the new location. Examples:
It is possible to retrieve the current pen location with the POSXY command. This command will assign the pen's position to the receiver variables specified.
Syntax: print #handle, "POSXY X Y"
As it would appear in a program:
print #1, "posxy xVar yVar"
After this command, the values for the current pen position are contained in the variables xVar and yVar.
OBJECTS
There are several objects that can be drawn. They are:
LINE
BOX
BOXFILLED
CIRCLE
CIRCLEFILLED
ELLIPSE
ELLIPSEFILLED
PIE
PIEFILLED
For all except the line, if the command contains "FILLED", the object will be a solid object, filled with the current BACKCOLOR. It will completely cover all drawn objects beneath it. Objects that aren't "FILLED" are drawn as outlines. Any drawn graphics that already exist on the screen under the new object will still be visible within its borders. Here is a small demo. Notice how the graphics beneath the box show within its borders, while the graphics beneath the boxfilled are covered by the BACKCOLOR.
The LINE command draws a line in the current pen color and size, from the first pair of points to the second pair of points. If the pen is UP, the pen will move, but no line will be drawn.
The two BOX commands draw a box from the current pen position to the x,y position given. BOX draws an outline of a box in the current pen color and size. BOXFILLED draws a box using the current pen size and color and fills it with the current BACKCOLOR.
The two CIRCLE commands draw a circle from the current pen position with the radius given. The radius specifies the distance in pixels from the center of the circle to its outside edge. CIRCLE draws an outline of a circle in the current pen color and size. CIRCLEFILLED draws a circle using the current pen size and color and fills it with the current BACKCOLOR.
The two ELLIPSE commands draw an ellipse centered at the current pen position with the width and height given. ELLIPSE draws an outline of an ellipse in the current pen color and size. ELLIPSEFILLED draws an ellipse using the current pen size and color and fills it with the current BACKCOLOR.
The two PIE commands draw a pie section inside of an ellipse whose width and height are given. The starting and stopping points of the ellipse are expressed in angles. The PIE will start at the first angle and sweep clockwise to the second angle, if the second angle is positive. It will sweep counter-clockwise to the second angle if the second angle is negative. The figure can appear to be any section of a pie: a thin slice, a quarter, half or three-quarters of a pie, or even an entire pie ellipse, if the two angles are equal.
Drawn Objects
A Beginning Graphics Tutorial-
Drawn Objects | SIZE | FILL and CLS | COLOR | BACKCOLOR | LOCATION | OBJECTS | LINE | BOX, BOXFILLED | CIRCLE, CIRCLEFILLED | ELLIPSE, ELLIPSEFILLED | PIE, PIEFILLED There are two kinds of graphics available in Liberty BASIC, turtle graphics, and objects. The turtle graphics method employs a drawing pen that moves about the screen, leaving a trail if the pen is down. Objects and turtle graphics can be drawn together, but it is more usual to see one or the other in a program. For more about turtle graphics, see TurtleGraphics
For any graphics, the first important lesson is that the pen must be in the DOWN position for graphics to display on the screen. The default is UP, so remember to issue the DOWN command to start drawing.
SIZE
By default, the drawing pen is a single pixel wide. It can be made any size with the SIZE comand. Remember that objects drawn with a larger-sized pen will take up more space than objects drawn with the default 1-pixel-wide pen. To issue the size command:
Remember that variables must be placed outside of the quote marks and that blank spaces must be preserved.
FILL and CLS
The FILL command causes the graphicbox or graphics window to be filled with the designated color. This will cover any existing graphics. FILL can be a named Liberty BASIC color, or an RGB color. For more, see ColorInGraphics. To clear the screen and erase drawn objects from memory, issue a CLS command.
COLOR
Objects are drawn with a pen in the COLOR chosen. The default color is black. To change the color at any time in a program, issue a COLOR command. Objects will be drawn in that color until another COLOR command is issued. The color can be a named Liberty BASIC color, or an RGB color. For more, see ColorsInGraphics Examples of the COLOR command:
BACKCOLOR
Objects can be drawn as outlines, or as objects filled with a color. Filled objects are filled with the current BACKCOLOR. The default BACKCOLOR is white. For more, see ColorInGraphics. BACKCOLOR can be a named Liberty BASIC color, or an RGB color. It will be used to fill drawn objects until another BACKCOLOR command is issued. Examples of the BACKCOLOR command.
LOCATION
The pen starts at point 0, 0. This is the upper left corner of the graphics area. The x values get larger as you move right and the y values get larger as you move down. You can locate the pen using turtle graphics commands. See TurtleGraphics It is more common to locate the pen using the PLACE command when drawing objects. This command puts the drawing pen at the x,y location given. The pen does not draw a line from its previous position. It is lifted and placed at the new location. Examples:
It is possible to retrieve the current pen location with the POSXY command. This command will assign the pen's position to the receiver variables specified.
Syntax: print #handle, "POSXY X Y"
As it would appear in a program:
After this command, the values for the current pen position are contained in the variables xVar and yVar.
OBJECTS
There are several objects that can be drawn. They are:
LINE
BOX
BOXFILLED
CIRCLE
CIRCLEFILLED
ELLIPSE
ELLIPSEFILLED
PIE
PIEFILLED
For all except the line, if the command contains "FILLED", the object will be a solid object, filled with the current BACKCOLOR. It will completely cover all drawn objects beneath it. Objects that aren't "FILLED" are drawn as outlines. Any drawn graphics that already exist on the screen under the new object will still be visible within its borders. Here is a small demo. Notice how the graphics beneath the box show within its borders, while the graphics beneath the boxfilled are covered by the BACKCOLOR.
LINE
The LINE command draws a line in the current pen color and size, from the first pair of points to the second pair of points. If the pen is UP, the pen will move, but no line will be drawn.
Syntax: print #handle, "X1 Y1 X2 Y2"
As it would appear in a program:
BOX, BOXFILLED
The two BOX commands draw a box from the current pen position to the x,y position given. BOX draws an outline of a box in the current pen color and size. BOXFILLED draws a box using the current pen size and color and fills it with the current BACKCOLOR.
Syntax: print #handle, "BOX X Y"
As it would appear in a program:
CIRCLE, CIRCLEFILLED
The two CIRCLE commands draw a circle from the current pen position with the radius given. The radius specifies the distance in pixels from the center of the circle to its outside edge. CIRCLE draws an outline of a circle in the current pen color and size. CIRCLEFILLED draws a circle using the current pen size and color and fills it with the current BACKCOLOR.
Syntax: print #handle, "CIRCLE R"
As it would appear in a program:
ELLIPSE, ELLIPSEFILLED
The two ELLIPSE commands draw an ellipse centered at the current pen position with the width and height given. ELLIPSE draws an outline of an ellipse in the current pen color and size. ELLIPSEFILLED draws an ellipse using the current pen size and color and fills it with the current BACKCOLOR.
Syntax: print #handle, "ELLIPSE W H"
As it would appear in a program:
PIE, PIEFILLED
The two PIE commands draw a pie section inside of an ellipse whose width and height are given. The starting and stopping points of the ellipse are expressed in angles. The PIE will start at the first angle and sweep clockwise to the second angle, if the second angle is positive. It will sweep counter-clockwise to the second angle if the second angle is negative. The figure can appear to be any section of a pie: a thin slice, a quarter, half or three-quarters of a pie, or even an entire pie ellipse, if the two angles are equal.
Syntax: print #handle, "PIE W H A1 A2"
As it would appear in a program:
Here is a small pie demo:
Drawn Objects | SIZE | FILL and CLS | COLOR | BACKCOLOR | LOCATION | OBJECTS | LINE | BOX, BOXFILLED | CIRCLE, CIRCLEFILLED | ELLIPSE, ELLIPSEFILLED | PIE, PIEFILLED