Site hosted by Angelfire.com: Build your free website today!

Line, Circle and Pset

Line

This is a very handy command, used to draw a line from one point to another, or it can be used to draw boxes. First of all, lines. All you have to do to draw a line is specify the starting point of the line, and the ending point of the line. This can be done in several different ways; mainly steps and coordinates. Coordinates are pretty straight forward. You specify the starting point, and the ending point (as I said earlier), like this.

line (1, 1)-(5, 5)

That is line, then the starting coordinates in parentheses, a hyphen, then the ending coordinates in parentheses again. This draws a diagonal line from the upper left corner of the screen, to the fifth pixel over, and the fifth pixel down. There are several options you can put on the end of this command. Here's an example:

line (1, 1)-(5, 5), 1

This draws a line that is blue, rather than white, which is the default color. Another option is the B, or the BF option. B draws a box with the upper left corner as the starting coordinates, and the lower right as the ending coordinates. It will be an unfilled box. BF draws a filled box. Here's another example:

line (1, 1)-(5, 5), 1, BF

This is a square five pixels across in the upper left corner of the screen that is filled and blue in color. Now then, I mentioned earlier about using steps to specify coordinates. What you can do is, type the starting coordinates, then type how many pixels you want to line to be up, and then how many pixels to the side. That seemed confusing even to me, so here's an example:

line (1, 1)-step(4, 4), 1

This example draws the same line as all the others have, but it uses steps to define the coordinates. This can be handy if you happen to have to change the location of a lot of lines, but don't want to have to change the ending coordinates too. I recommend that you load QBasic and try this one so you can see what it does. It's a little difficult to explain this option for the line command. Here's another example, and let's say that it comes right after the one just above that I told you to try out.

line step (0, 0)-step(5, 5), 1

If you put this right after the example before it, you should end up with a line that is ten pixels long, rather than five. You see, what the first step function is telling you is that it should start drawing 0 pixels vertically, and 0 pixels horizontally from the most recently drawn postition. This is also handy for complicated pictures so you don't have to figure out where the line you just drew ends so you know where to start drawing a nearby line. You can just use a step command. I think this covers the line command.

Circle

Circle is a pretty self explanatory command. It draws a circle like this; first you type circle (no kidding!), then you type in the coordinates for the center of the circle (these should be in parentheses), then you type in how large you want the circle to be (type the radius). Example:

circle (10, 10), 5

That draws a circle ten pixels across (diameter) in the upper left corner of the screen. Now, you ask, how does one change the color (well, maybe not, but I'll tell you anyway). Simple, you add the number of the color on the end of the code with another comma in between it and the radius. I don't really think you should need an example of this one, but I'll give you one anyway:

circle (10, 10), 5, 4

That draws a red circle, instead of the default white one. There are some other things you can do with this command, so maybe I'll put it again in the Advanced Tutorials section (if I ever start one), and show them to you. However, for right now, this should be all you need to know.

PSET

This command pset fills in one pixel of the screen with a specified color. You define the coordinates of the pixel the same way you do with the center of the circle in the circle command. Here's an example:

pset (10, 10), 1

This makes the tenth pixel down and the tenth pixel over blue. Pset is also an actionverb for the put statement, which we'll get into later. That about covers pset (not exactly a difficult command). If you want a faster alternative to pset, I'll be working on that soon. It's called POKE, and is a lot more advanced than this is, using DEF SEG commands and such.

Back to the Tutorials...

Email: cybertron@flashmail.com