Download text file
$if 0
  Hi,

    The use of this code on any of the screen modes directly supported by
  PowerBASIC would be, to say the least, a bit redundant. I wrote it as a
  model for my VESA routines.

    I _REALLY_ feel that there is some element of the logic that I'm
  missing that is causing the routine to make too many iterations but I
  can't figure what it is. Maybe you can get it.

  C'ya,

  Don
  d83@DASoftVSS.com

$endif

'.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø.ø
' ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø ø

$STACK 32766                                 ' recursive routine needs room
$OPTIMIZE SPEED                              ' make it fast Bob!
                                             '
PUBLIC pMaxX%                                ' screen boundries
PUBLIC pMaxY%                                '
                                             '
SCREEN 12                                    ' graphics screen
pMaxX% = 639                                 ' set screen boundries
pMaxY% = 479                                 '
                                             '
DELAY 2                                      ' give monitor time to switch
                                             '
CIRCLE (320, 240), 100, 15, -2.7, -1.9, .83  ' an oddball pie shape
LINE (0,0)-(pMaxX%,pMaxY%), 15, B            ' border around the screen
LINE (pMaxX%,0) - (pMaxX%,pMaxY%), 0         ' (remove right side)
LINE (pMaxX%,0)-(500,240), 15                ' put in a divit
LINE (500,240) - (pMaxX%,pMaxY%), 15         '
                                             '
MyPaint -10, 1000, 3, 15                     ' test stupid
                                             '
T1! = TIMER                                  '
MyPaint 340, 200,  4, 15                     ' fill pie shape
T1! = TIMER - T1!                            '
DELAY 1                                      '
T2! = TIMER                                  '
MyPaint 242,   2, 12, 15                     ' fill large screen area
T2! = TIMER - T2!                            '
DELAY 1                                      '
T3! = TIMER                                  '
MyPaint 503, 240, 13, 15                     ' fill in divit
T3! = TIMER - T3!                            '
LOCATE 2, 2                                  '
PRINT USING "##.#### "; T1!, T2!, T3!        ' display times
                                             '
WHILE INSTAT : G$ = INKEY$ : WEND            ' wait for the user
WHILE NOT INSTAT : WEND                      '
SCREEN 0                                     '
END                                          ' END OF PROGRAM

' --------------------------------------------------------------------------
' ------------------------- START HERE -------------------------------------
' --------------------------------------------------------------------------

SUB MyPaint( BYVAL Xstart AS INTEGER, _
             BYVAL Ystart AS INTEGER, _
             BYVAL Colour AS INTEGER, _
             BYVAL Border AS INTEGER  ) LOCAL PUBLIC

  DIM Clr   AS LOCAL INTEGER                         ' on screen pixel color
  DIM LastX AS LOCAL INTEGER                         ' right most X position
  DIM LeftX AS LOCAL INTEGER                         ' left most X position
  DIM X     AS LOCAL INTEGER                         ' current X position
  DIM Y     AS LOCAL INTEGER                         ' current Y position
                                                     '
  FOR X% = Xstart% TO 0 STEP -1                      ' check left of start
    IF ( POINT(X%,Ystart%) = Border% ) THEN EXIT FOR ' hit the border here
    PSET (X%,Ystart%), Colour%                       ' paint this pixel
  NEXT                                               '
  LeftX% = X% + 1                                    ' store left most point
                                                     '
  FOR X% = Xstart% +1 TO pMaxX%                      ' check right of start
    IF ( POINT(X%,Ystart%) = Border% ) THEN EXIT FOR ' hit the border
    PSET (X%,Ystart%), Colour%                       ' paint this pixel
  NEXT                                               '
  LastX% = X% - 1                                    ' store right most point
                                                     '
  FOR Y% = Ystart% -1 TO Ystart% + 1 STEP 2          ' check above/below
    IF ( Y% < 0      ) THEN ITERATE                  ' past top of screen
    IF ( Y% > pMaxY% ) THEN ITERATE                  ' past bottom of screen
    FOR X% = LeftX% TO LastX%                        ' check line
      Clr% = POINT(X%,Y%)                            ' get pixel value
      IF Clr% = Colour% THEN ITERATE                 ' if already painted
      IF Clr% = Border% THEN ITERATE                 ' if border color
      IF ( POINT(X%-1,Y%) = Border% ) AND _          ' check left/right
         ( POINT(X%+1,Y%) = Border% ) THEN ITERATE   '
      MyPaint X%, Y%, Colour%, Border%               ' recall to paint line
    NEXT                                             '
  NEXT                                               '
                                                     '
END SUB                                              '