BBS: Inland Empire Archive Date: 01-25-93 (19:07) Number: 332 From: SCOTT WUNSCH Refer#: NONE To: SEAN PAGE Recvd: NO Subj: PAINT command Conf: (2) Quik_Bas
Salutations, Sean!
While violating the Neutral Zone on stardate 23 Jan 93,
Captain Sean Page opened hailing frequencies to the U.S.S.
All to say this:
SP> Does anyone know of or have source code that will do a complete paint
SP> routine. Not like QB's paint, but un actual fill command a-la Windows
SP> PaintBrush style fill. I need a routine that will fill an enclosed area
SP> regardless of it's bordercolor.
Well, courtesy of resident EchoGenius Rich Geldreich <g>...
Well, back when I was in 8th grade, while the other
kids where probably playing hockey or something :-), I
created this algorithm on an old Color Computer 2. It's
not that practical, because it is constantly throwing &
removing things from its ring buffer, but it works!
It's currently set up for a snake fill. To see a diamond fill (which
is much more efficient that a snake fill, FWIW), then
look at the very end of the program and remark/unremark
some lines... The snake fill looks cool, while the
diamond fill is rather dull...
Rich
'A Snake fill
DEFINT A-Z
CONST RSize = 10000
TYPE SpillType
x AS INTEGER
y AS INTEGER
t AS INTEGER
END TYPE
DIM Ring(RSize - 1) AS SpillType
SCREEN 13
CLS
RANDOMIZE -3500
FOR A = 1 TO 35: x1 = RND * 320: y1 = RND * 200
x2 = RND * 320: y2 = RND * 200: LINE (x1, y1)-(x2, y2), 14: NEXT
LINE (0, 0)-(219, 199), 0: LINE (1, 0)-(220, 199), 0
LINE (319, 0)-(160, 150), 0: LINE (318, 0)-(159, 150), 0
RingIn = 0: RingOut = 0
cx = 160: cy = 150: t = 0
IF POINT(cx, cy) = 0 THEN
PSET (cx, cy), 9
DO
IF cy > 0 AND t <> 4 THEN
IF POINT(cx, cy - 1) = 0 THEN
PSET (cx, cy - 1), 9
Ring(RingIn).x = cx: Ring(RingIn).y = cy - 1: Ring(RingIn).t = 3
RingIn = (RingIn + 1) MOD RSize
END IF
END IF
IF cx < 320 AND t <> 2 THEN
IF POINT(cx + 1, cy) = 0 THEN
PSET (cx + 1, cy), 9
Ring(RingIn).x = cx + 1: Ring(RingIn).y = cy: Ring(RingIn).t = 1
RingIn = (RingIn + 1) MOD RSize
END IF
END IF
IF cy < 200 AND t <> 3 THEN
IF POINT(cx, cy + 1) = 0 THEN
PSET (cx, cy + 1), 9
Ring(RingIn).x = cx: Ring(RingIn).y = cy + 1: Ring(RingIn).t = 4
RingIn = (RingIn + 1) MOD RSize
END IF
END IF
IF cx > 0 AND t <> 1 THEN
IF POINT(cx - 1, cy) = 0 THEN
PSET (cx - 1, cy), 9
Ring(RingIn).x = cx - 1: Ring(RingIn).y = cy: Ring(RingIn).t = 2
RingIn = (RingIn + 1) MOD RSize
END IF
END IF
'The following 3 lines give a "snake" fill.
IF RingIn = 0 THEN EXIT DO
RingIn = RingIn - 1
cx = Ring(RingIn).x: cy = Ring(RingIn).y: t = Ring(RingIn).t
'Unremark the following 3 lines and remark the 3 lines above
'to see a "diamond" fill...
'IF RingIn = RingOut THEN EXIT DO
'cx = Ring(RingOut).x: cy = Ring(RingOut).y: t = Ring(RingOut).t
'RingOut = (RingOut + 1) MOD RSize
LOOP
END IF
-+- MsgToss 2.0b
+ Origin: Computer Co-Op - Voorhees, NJ | Ted Hare (1:266/29)
That's all, folks!
/\ LLAP...
> \ cott \\'unsch <
\/
... Al, I just leaped into a tagline. What does Ziggy say?
---
* Origin: Regina, Sask, Canada, Earth, Sol System, Milky Way (1:140/23.1701)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET