So far you have been looking at adding text output and text input in BASIC-256. Today we will start using the drawing ability of the software.
Any graphics you want to appear in your program must be programmed using commands just like entering the “print” command. In BASIC-256 the graphics are drawn in the area below the Graphics Output section of the program.
It helps to think of the graphics area as a grid where the graphics are drawn. Each line on the grid is one pixel when it is drawn on the screen.
The grid has numbers across the top starting with 0 at the left side.
The grid also has numbers on the left side starting with 0 in the top left corner.
Each point on the grid is made up of two numbers. The first number shows how far from the left the point is drawn. The second number shows how far down the point is drawn. This example would draw the point over one pixel and down one pixel.
This point is drawn over three pixels and down two pixels. This point would be named 3,2.
This point is drawn over five pixels and down six pixels. This point would be named 5,6.
What is the name of this point? If you are stuck, think how many pixels over and how many pixels down.
This point is over eight pixels and down two pixels. The name of this point is 8,2.
What is the name of this point? If you are stuck, think how many pixels over and how many pixels down.
This point is over six pixels and down eight pixels. The name of this point is 6,8.
What is the name of this point?
The point is 8,4. Over eight pixels and down four pixels.
In addition to points, the BASIC-256 program can draw lines on the screen. In order to draw a line you find the name of the point that is where the lines starts and the name of the point where the line ends. In this example the line starts at point 1,1 and ends at point 5,6.
In order for the program the draw a line in the graphics output, the program needs a command. The command to draw a line is the word line followed by four numbers. The first set of numbers are the name of the starting point. The second set of numbers are the name of the ending point. These two sets of numbers are joined together with another comma. To draw this line on the screen you would type the command line one comma one comma five comma six.
Lines can be connected together when they are drawn on the screen. Each line needs its own line command made up of four numbers. Where will this line be drawn on the screen? If you are stuck think about the starting point and the ending point of the line. The first two numbers are the starting point and the second two numbers are the ending point.
This line would start at point 5,6 and end at point 9,6.
What command would be used to draw the new line on the screen?
The command would be line nine comma six comma seven comma two. The line starts at point 9,6 and ends at point 7,2. Both these points are combined with a comma in the line command.
The BASIC-256 program can also use a rectangle command to draw a colored rectangle on the screen. In order to draw a rectangle find the point where the rectangle should start.
The rectangle is drawn from this starting point. Two more numbers are needed to draw the rectangle on the screen.
The next number is how far over the rectangle should be drawn from the starting point. This is the width of the rectangle.
The last number is how far down the rectangle should be drawn from the starting point. This is the height.
The rectangle command is made up of the starting point followed by a comma. The number of pixels over, comma and the number of pixels down.
What command would be used to draw this rectangle on the screen. If you get stuck, think about the starting point, how far over and how far down.
The command would be rect two comma three comma six comma four. The rectangle starts at point 2,3 and is drawn over six pixels and down four pixels.
The last graphics shape in BASIC-256 is the circle. Just like the rectangle the first thing to do is figure out the point where the circle starts.
The only other number needed is how far from the center to draw the circle. Count from the center of the circle to the edge. This number is the radius.
What command would be used to draw this rectangle on the screen. If you get stuck, think about the starting point, and the radius.
The command would be circle six comma four comma three. The circle starts at point 6,4 and is three pixels from the center.