Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to figure algorithm to draw and paint polygons
#7
Refactor step 1:

Code: (Select All)
PSET (50,25) : AreaStartX = POINT(0) : AreaStartY = POINT(1)
LeftMostX = POINT(0) : LeftMostY = POINT(1) : LeftMostXBud2 = -1 : LeftMostYBud2 = -1
LastX = POINT(0): LastY = POINT(1)

SUB DoPostLine()
    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

LINE - (500,15),14 : DoPostLine()

LINE - (490,190),14 : DoPostLine()

LINE - (400,150),14 : DoPostLine()

LINE - (430,40),14 : DoPostLine()

LINE - (150,50),14 : DoPostLine()

LINE - (150,120),14 : DoPostLine()

LINE - (290,80),14 : DoPostLine()

LINE - (150,180),14 : DoPostLine()

LINE - (75,160),14 : DoPostLine()

LINE - (AreaStartX, AreaStartY), 14
IF POINT(0) = LeftMostX THEN LeftMostXBud1 = LastX : LeftMostYBud1 = LastY
LastX = POINT(0): LastY = POINT(1)

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
Reply


Messages In This Thread
RE: Trying to figure algorithm to draw and paint polygons - by CharlieJV - 08-14-2023, 02:55 AM



Users browsing this thread: 2 Guest(s)