ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· PowerBASIC v3.20 ÚÄÄ´ DASoft ÇÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ· ³ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĶ Copyright 1995 ³ DATE: 1995-10-01 ÇÄ· ³ ³ FILE NAME POLYGONS.TXT º by ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÄ º º ³ ³ º Don Schullian, Jr. º º ³ ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º º ³ A license is hereby granted to the holder to use this source code in º º ³ any program, commercial or otherwise, without receiving the express º º ³ permission of the copyright holder and without paying any royalties, º º ³ as long as this code is not distributed in any compilable format. º º ³ IE: source code files, PowerBASIC Unit files, and printed listings º º ÔÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ º ³ .................................... º ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Here is a set of routines that will either allow you to compute the required points of a polygon or draw the object complete. In fact, the use of the word polygon may not be totally correct as there is a star, a circle, an arc, and a 3-D oval routine included! Most of these items are geometrically complicated and require several variables. A TYPE is used pass all the many variables into and around the routines and the PUBLIC variable pPi# is required. You'll have to become familiar with PolygonTYPE and how it is used to traverse these waters but no worry! The logic used in these routines is plane geometry and a bit past my kin, but all the figures are based on one or two circles. The star and the 3-D polygon both use two circles to get things drawn. There are a few restrictions on the 3-D routine due to it's logic and some natural blocks to all of them due to the composition of the universe we happen to be stuck in! The routines are not CAD quality and are not meant to be but they get real useful every now and again and are very fast! The best part is that the figures can be drawn using XORed logic! And that brings us to PlotCircle. By no means is this a replacement for CIRCLE as it really doesn't do as good a job and is slower than dirt, BUT it can be XORed on and off! This makes it possible to use a dotted circle until the correct position is found then use CIRCLE to do the finished product. Once you have set the values for the members of PolygonTYPE you need to call PolygonReady so the last four members can be computed. Repeat this if you change t.Radius, t.Aspect, t.Points, and/or t.Start. Any changes here will result in changes to at least one of the last four members also. Once you've got all this done you may compute all points or any one point by calling PolygonPoints or PolygonPoint. To capture all the points you will require an INTEGER ARRAY XYs%(0:1,0:t.Points). Elements 0,0 and 0,1 are loaded with the same values as the last point so the last side of the polygon can be drawn. The last item to take in to account is when you are drawing a 3-D figure or a STAR. The second TYPE for the back or inside does not always follow all the rules! You will want to pay particular attention to the screens for each of these figures in regards to the different values. However you use these routines I am sure that you will find them not only productive but also fun! They are fast enough to create animated sequences such as spinning stars, moving boxes, etc. This makes them a favorite for preschooler games and educational demonstrations.