Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to figure algorithm to draw and paint polygons
#10
Sometimes, things have to get bigger and uglier before they can get compact and purty.

Program modified to redraw the polygon over and over again in an infinite loop, but changing the starting coordinate of the polygon every loop.

Code: (Select All)
TYPE a_point
x%
y%
END TYPE

DIM array(1 TO 10) AS a_point
DIM point_hold as a_point
DIM as integer LeftMostX, LeftMostY, LastX, LastY,  LeftMostXBud1, LeftMostYBud1, LeftMostXBud2, LeftMostYBud2, AreaStartX, AreaStartY

SUB DoPostLine()
_delay 0.25
    IF POINT(0) < LeftMostX THEN
      LeftMostX = POINT(0) : LeftMostY = POINT(1) : LeftMostXBud1 = LastX : LeftMostYBud1 = LastY : LeftMostXBud2 = -1 : LeftMostYBud2 = -1
    ELSE
      IF LeftMostXBud2 = -1 THEN LeftMostXBud2 = POINT(0) : LeftMostYBud2 = POINT(1)
    END IF
    LastX = POINT(0): LastY = POINT(1)
END SUB

FOR i = 1 TO 10
  READ array(i).x%, array(i).y%
NEXT i

DrawAgain:

CLS

PSET (array(1).x%,array(1).y%) : AreaStartX = POINT(0) : AreaStartY = POINT(1)
LeftMostX = POINT(0) : LeftMostY = POINT(1) : LeftMostXBud1 = -1 : LeftMostYBud1 = -1 : LeftMostXBud2 = -1 : LeftMostYBud2 = -1
LastX = POINT(0): LastY = POINT(1)

LINE - (array(2).x%,array(2).y%),14 : DoPostLine()

LINE - (array(3).x%,array(3).y%),14 : DoPostLine()

LINE - (array(4).x%,array(4).y%),14 : DoPostLine()

LINE - (array(5).x%,array(5).y%),14 : DoPostLine()

LINE - (array(6).x%,array(6).y%),14 : DoPostLine()

LINE - (array(7).x%,array(7).y%),14 : DoPostLine()

LINE - (array(8).x%,array(8).y%),14 : DoPostLine()

LINE - (array(9).x%,array(9).y%),14 : DoPostLine()

LINE - (array(10).x%,array(10).y%),14 : DoPostLine()

IF LeftMostXBud1 = -1 THEN LeftMostXBud1 = POINT(0) : LeftMostYBud1 = POINT(1)

LINE - (AreaStartX, AreaStartY), 14 : DoPostLine()

IF LeftMostXBud1 < LeftMostXBud2 THEN PAINT ( (LeftMostX + LeftMostXBud1) / 2 + 1, (LeftMostY + LeftMostYBud1) / 2 ), 1, 14 ELSE PAINT ( (LeftMostX + LeftMostXBud2) / 2 + 1, (LeftMostY + LeftMostYBud2) / 2 ), 1, 14

IF LeftMostXBud1 < LeftMostXBud2 THEN CIRCLE ( (LeftMostX + LeftMostXBud1) / 2 + 1, (LeftMostY + LeftMostYBud1) / 2 ), 10, 12 ELSE CIRCLE ( (LeftMostX + LeftMostXBud2) / 2 + 1, (LeftMostY + LeftMostYBud2) / 2 ), 10, 12

_DELAY 1

point_hold.x% = array(1).x% : point_hold.y% = array(1).y%
array(1).x% = array(2).x% : array(1).y% = array(2).y%
array(2).x% = array(3).x% : array(2).y% = array(3).y%
array(3).x% = array(4).x% : array(3).y% = array(4).y%
array(4).x% = array(5).x% : array(4).y% = array(5).y%
array(5).x% = array(6).x% : array(5).y% = array(6).y%
array(6).x% = array(7).x% : array(6).y% = array(7).y%
array(7).x% = array(8).x% : array(7).y% = array(8).y%
array(8).x% = array(9).x% : array(8).y% = array(9).y%
array(9).x% = array(10).x% : array(9).y% = array(10).y%
array(10).x% = point_hold.x% : array(10).y% = point_hold.y%

GOTO DrawAgain

END

DATA 50, 25
DATA 500,15
DATA 490,190
DATA 400, 150
DATA 430,40
DATA 150,50
DATA 150, 120
DATA 290, 80
DATA 150, 180
DATA 75, 160
Reply


Messages In This Thread
RE: Trying to figure algorithm to draw and paint polygons - by CharlieJV - 08-17-2023, 10:03 PM



Users browsing this thread: 1 Guest(s)