Hi Again:

Here is a subroutine to draw the largest polygon or "circle" on a m200
screen:    (This relates to the m100 discussion list on 10/16/26 regarding
a CIRCLE() command for the Model-T computers.)

10 'DRAW REG POLYGON OR "CIRCLE"
20 CLS
35 XC=120:YC=63 'SET SCREEN CTR
40 R=63 'SET RADIUS IN PIXELS
50 N=24 'SET NO. OF SIDES
60 PI=4*ATN(1) 'SET SINGLE PRECISION PI
70 DA=(2*PI)/N 'ANGLE STEP PER VERTEX
90 X1=XC+R*COS(0):Y1=YC+R*SIN(0) 'CALC 1ST VERTEX
110 X0=X1 'SAVE START POINT
120 FOR I=1TON 'STEP
130 A=I*DA
140 X2=XC+R*COS(A):Y2=YC+R*SIN(A)
160 LINE (X1,Y1)-(X2,Y2)
170 X1=X2:Y1=Y2
180 NEXTI
190 END

I am a "novice" m100-BASIC programmer so you will forgive any violation of
your sensibilities. The code works well when drawing a figure with a low
number of corners  or "vertices", like a triangle or petagon. But you will
see if you draw a polygon with a low radius value (like 10) with a high
number of sides (like 24) it starts to look like a piece of "popcorn".  I
wrote it originally in GWBasic and there it takes on an elongated
appearance due to the aspect ratio of GWbasic for an early PC screen. Hence
the ability of the CIRCLE() command in GWBasic to change the aspect ratio
to make the circle look better. On the m200 I'm guessing that the pixels
are more square so it looks OK as is.

1.) In the real world (whatever that is?) I would add code to save the
coordinates of the vertices to an array. Then take the coordinates and draw
a polygon from that. It would take less code and save processing time. But
for just "playing" around this is OK.

2.) In books relating to the Model-T computers they always plot the
individual points of a circle, which looks better but takes an eternity to
draw.

3.) For the m100 screen size one will have to reduce the values of YC in
line 35 and R in line 40 accordingly.

4.) As expected, values exceeding screen size will cause an error.

Attachment: POLY01A.pdf
Description: Adobe PDF document

Reply via email to