Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The simplest paint routine.
#5
The benchmark, gentlemen:

Code:
DECLARE SUB fill (array1() AS INTEGER, x AS INTEGER, y AS INTEGER, fillcolor AS INTEGER)
DIM SHARED map(1 TO 40, 1 TO 40) AS INTEGER
SCREEN 13
fill map(), 5, 5, 6 'array must start at 1
FOR y% = 1 TO 40
FOR x% = 1 TO 40
PSET (x%, y%), map(x%, y%)
NEXT x%, y%

SUB fill (array1() AS INTEGER, x0 AS INTEGER, y0 AS INTEGER, fillcolor AS INTEGER)
DIM i AS INTEGER, j AS INTEGER, k AS INTEGER, h AS INTEGER, endk AS INTEGER
floorcolor% = array1(x0, y0)
x.max% = UBOUND(array1, 1)
y.max% = UBOUND(array1, 2)
iteration.max = x.max% * y.max% / 2
DIM path.x(1 TO iteration.max) AS INTEGER, path.y(1 TO iteration.max) AS INTEGER
path.x(1) = x0
path.y(1) = y0
array1(x0, y0) = fillcolor%
j = 1
DO
DO
IF i = iteration.max THEN i = 1 ELSE i = i + 1
x% = path.x(i)
y% = path.y(i) + 1
GOSUB thepudding
y% = y% - 2
GOSUB thepudding
y% = y% + 1
x% = x% - 1
GOSUB thepudding
x% = x% + 2
GOSUB thepudding
IF i = j THEN EXIT DO
LOOP
IF j = k THEN EXIT DO
j = k
i = i - 1
LOOP
ERASE path.x, path.y
EXIT SUB
thepudding:
IF x% < 1 THEN RETURN
IF y% < 1 THEN RETURN
IF x% > x.max% THEN RETURN
IF y% > y.max% THEN RETURN
IF array1(x%, y%) <> floorcolor% THEN RETURN
IF k = iteration.max THEN k = 1 ELSE k = k + 1
path.x(k) = x%
path.y(k) = y%
array1(x%, y%) = fillcolor%
RETURN
END SUB
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply


Messages In This Thread
The simplest paint routine. - by Rokkuman - 07-12-2003, 03:56 AM
The simplest paint routine. - by whitetiger0990 - 07-12-2003, 04:08 AM
The simplest paint routine. - by toonski84 - 07-12-2003, 04:31 AM
The simplest paint routine. - by Agamemnus - 07-12-2003, 07:10 AM
The simplest paint routine. - by Plasma - 07-12-2003, 07:53 AM
The simplest paint routine. - by Antoni Gual - 07-12-2003, 02:25 PM
The simplest paint routine. - by Plasma - 07-12-2003, 08:04 PM
The simplest paint routine. - by Agamemnus - 07-12-2003, 08:14 PM
The simplest paint routine. - by Antoni Gual - 07-14-2003, 01:32 PM
The simplest paint routine. - by Antoni Gual - 07-14-2003, 02:17 PM
The simplest paint routine. - by Plasma - 07-15-2003, 03:04 AM
The simplest paint routine. - by Antoni Gual - 07-15-2003, 06:13 PM
The simplest paint routine. - by Plasma - 07-15-2003, 07:11 PM
The simplest paint routine. - by Agamemnus - 07-15-2003, 09:39 PM
The simplest paint routine. - by Nexinarus - 07-16-2003, 05:00 AM
My code - by Meg - 07-16-2003, 07:22 AM
. - by Meg - 07-18-2003, 08:13 AM
Re: My code - by Mango - 07-18-2003, 08:47 AM
oops - by Meg - 07-18-2003, 10:01 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)