' ****** START INCLUDE Polygon Macro Support ******
DIM AS INTEGER StartX, StartY, PreviousX, PreviousY, LeftMostX, LeftMostY, LeftMostNear1X, LeftMostNear1Y, LeftMostNear2X, LeftMostNear2Y, LeftMostBuddyX, LeftMostBuddyY

SUB DoPostLine()
    IF POINT(0) < LeftMostX THEN
      LeftMostX = POINT(0) : LeftMostY = POINT(1) : LeftMostNear1X = PreviousX : LeftMostNear1Y = PreviousY : LeftMostNear2X = -1 : LeftMostNear2Y = -1
    ELSE
      IF LeftMostNear2X = -1 THEN LeftMostNear2X = POINT(0) : LeftMostNear2Y = POINT(1)
    END IF
    PreviousX = POINT(0): PreviousY = POINT(1)
END SUB
'  ****** END INCLUDE Polygon Macro Support ******

' Program by Charlie Veniot
' This program could be done with just DRAW statements.  No advantage here to using POLYGON.
' This is only meant to test the POLYGON macro and the include library to make sure they behave.
' Well, side benefit: demonstration program !
' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.08.08.01.01]) on 2023.08.19 at 00:28 (Coordinated Universal Time)

TYPE StarPoint
  x%
  y%
END TYPE

DIM BigStarPoint(0 TO 4) AS StarPoint
DIM SmlStarPoint(0 TO 4) AS StarPoint

SmallStarSize = 149
SmallStarAdj = 1

SCREEN _NEWIMAGE(301,301,12)
ADJ = 0
AGAIN:
CLS
FOR I = 0 TO 4
PSET (150,150), 0
DRAW "B C14 TA" + (72 * I + ADJ) + " U149"
BigStarPoint(I).x% = POINT(0) : BigStarPoint(I).y% = POINT(1)
PSET (150,150), 0
DRAW "B C14 TA" + (36 + 72 * I + ADJ) + " U" + SmallStarSize
SmlStarPoint(I).x% = POINT(0) : SmlStarPoint(I).y% = POINT(1)
NEXT I
PSET (BigStarPoint(0).x%,BigStarPoint(0).y%)  : StartX = POINT(0) : StartY = POINT(1) : LeftMostX = POINT(0) : LeftMostY = POINT(1) : LeftMostNear1X = -1 : LeftMostNear1Y = -1 : LeftMostNear2X = -1 : LeftMostNear2Y = -1 : PreviousX = POINT(0) : PreviousY = POINT(1)
LINE - (SmlStarPoint(0).x%,SmlStarPoint(0).y%),14 : DoPostLine()
LINE - (BigStarPoint(1).x%,BigStarPoint(1).y%),14 : DoPostLine()
LINE - (SmlStarPoint(1).x%,SmlStarPoint(1).y%),14 : DoPostLine()
LINE - (BigStarPoint(2).x%,BigStarPoint(2).y%),14 : DoPostLine()
LINE - (SmlStarPoint(2).x%,SmlStarPoint(2).y%),14 : DoPostLine()
LINE - (BigStarPoint(3).x%,BigStarPoint(3).y%),14 : DoPostLine()
LINE - (SmlStarPoint(3).x%,SmlStarPoint(3).y%),14 : DoPostLine()
LINE - (BigStarPoint(4).x%,BigStarPoint(4).y%),14 : DoPostLine()
LINE - (SmlStarPoint(4).x%,SmlStarPoint(4).y%),14 : DoPostLine()
IF LeftMostNear1X = -1 THEN LeftMostNear1X = POINT(0) : LeftMostNear1Y = POINT(1) 
 LINE - (StartX, StartY) ,14 : DoPostLine()

IF LeftMostNear1Y < LeftMostNear2Y THEN 

   LeftMostBuddyX = LeftMostNear1X : LeftMostBuddyY = LeftMostNear1Y 

ELSE 

   LeftMostBuddyX = LeftMostNear2X : LeftMostBuddyY = LeftMostNear2Y 

END IF 

PAINT ( (LeftMostX + LeftMostBuddyX) / 2 + IFF(LeftMostY>LeftMostBuddyY,1,-1) ,  (LeftMostY + LeftMostBuddyY) / 2 + 1 ),6,14
ADJ = ADJ + 1
If SmallStarSize > 148 or SmallStarSize < 4 THEN SmallStarAdj = - SmallStarAdj
SmallStarSize = SmallStarSize + SmallStarAdj
_DELAY 0.01
GOTO AGAIN