[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2004-07-30T23:11:40-05:00 http://www.petesqbsite.com/phpBB3/app.php/feed/topic/73 2004-07-30T23:11:40-05:00 2004-07-30T23:11:40-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=127#p127 <![CDATA[Curved Line and Oval Help]]> Statistics: Posted by Guest — Fri Jul 30, 2004 11:11 pm


]]>
2004-07-30T22:32:40-05:00 2004-07-30T22:32:40-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=125#p125 <![CDATA[Curved Line and Oval Help]]>
* 8.6 Creating Circles, Arcs, and Ovals
Another useful graphics command is CIRCLE. With CIRCLE, you need to not only specify its coordinates, but also its radius:

Code:

SCREEN 12  'creates a white (default color) circleCIRCLE (300, 200), 150END
The above will make a circle with a radius of 150 (remember, radius is the length from the center of the circle to its edge) at location (300, 200). The color of the circle is 15 (white) because that's the default color. To change the color, you can either:

Code:

SCREEN 12 'like the other graphics commands, the colorCOLOR 4   'will be that of the last COLOR command.CIRCLE (80, 240), 50END
or:

Code:

SCREEN 12CIRCLE (100, 100), 20, 7  '7 (gray) is the color END
With the CIRCLE command, you can create arcs or parts of a circle, using the start and end items. Start is where the circle will start, end is where the circle will end, both in radians.

Radians is a measurement of angles used in QBasic. There are 2 pi radians in a circle, where pi = 3.141593. So to convert degrees into radians, you multiply the degrees by (Pi / 180):

Code:

CLSINPUT "What is the angle in degrees?: ", degreesradians = degrees * (3.141593 / 180)PRINT degrees; "degrees ="; radians; "radians"END 
Here is a program that makes a half circle:

Code:

SCREEN 13CIRCLE (160, 100), 50, 14, 0, 3.1416END
Since 2 Pi makes a full circle, what makes a half circle was easy to figure out (Pi). Notice that 0 is the default starting point, so I don't really need it there. I could have done:

Code:

SCREEN 13CIRCLE (160, 100), 50, 14, , 3.1416END
Alright, so do you got that concept down? Do realize that 0 radians is to the right, not up.

Now there is another thing that we can do with the start and end arguments. If you make the start negative, then it will also draw a line from the starting point to the center of the circle. If the end is negative, then a line is drawn from the ending point to the center:

Code:

SCREEN 12CIRCLE (240, 240), 200, 13, -1.5708, -3.1416END
Remember that 1.5708 radians is up and 3.1416 radians is left. As you can see from running this program, that it makes a quarter pi shape figure.

An interesting problem arises with negative numbers in this situation. If you use a -0, then QBasic will treat it as a positive 0. What is one to do? We'll have to use a really small negative number opposed to using 0:

Code:

SCREEN 12RANDOMIZE TIMER             'creates a circle incolour = INT(RND * 15) + 1  'random color andendpoint = RND * 6.2832     'a random ending pointCIRCLE (200, 200), 150, colour, -.0001, -endpointEND
I decided to add a little mystery to the above program, just for a change of pace Notice that I used negative endpoint to make a line from the ending point to the center. I could have done RND * -6.2832, but I think it makes it slightly more readable the way I did it, but it doesn't really matter.

The last topic, of many, on CIRCLE is creating ovals. To create a oval, you must specific how many times higher the oval is than its width (this is called the aspect). So in this next example, the width is 100 and the height is 50 (.5 * 100):

Code:

SCREEN 12  'the row of commas is where the start            'and end properties would beCIRCLE (320, 240), 100, 15, , , .5END
You can also have the height greater than the width, by having a number greater than 1:

Code:

SCREEN 12CIRCLE (320, 240), 100, 15, , , 2END
However, notice that the height is 100 and the width is 50, not the height is 200 and the width is 100, like you'd think. I'm not quite sure why they did this, but when the aspect (the 2 in the above example) is greater than 1, the height is equal to the radius. However, if the aspect is less than 1, the width is equal to the radius. If you didn't just understand what I just said, you don't need to worry about it. You'll figure it out once you work with ovals.
This tutorial was originally here: http://www.geocities.com/alipha87/pkchap08.html


Play around with this command. The best way to learn this is by experimentation.

Statistics: Posted by Pete — Fri Jul 30, 2004 10:32 pm


]]>
2004-07-30T20:17:57-05:00 2004-07-30T20:17:57-05:00 http://www.petesqbsite.com/phpBB3/viewtopic.php?p=124#p124 <![CDATA[Curved Line and Oval Help]]> Thanks

Statistics: Posted by Me — Fri Jul 30, 2004 8:17 pm


]]>