Qbasicnews.com
September 19, 2019, 03:57:51 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: The simplest paint routine.  (Read 6561 times)
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #15 on: July 15, 2003, 01:39:23 PM »

:|
Logged

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.
Nexinarus
Wandering Guru
***
Posts: 301



WWW
« Reply #16 on: July 15, 2003, 09:00:50 PM »

After seeing yours, i decided i make one myself. its reasonably small/slim, i included an example with it. I avoided using ugly goto's Wink. And the array it uses is only 1023 elements and works with "the dot test".

http://hybd.net/~mms/files/FILL.BAS (put it here so the thread didnt get so huge Tongue)
Logged
Meg
Ancient QBer
****
Posts: 483


« Reply #17 on: July 15, 2003, 11:22:42 PM »

I'd much rather have used recursion, but here is my non-recursive entry:

NOTE: This was written for screen 13.  It can easily be adapted to other screen modes by changing the edge-limits (The ABS statements in the long line).

Code:
SUB FloodFill (x%, y%, c%)
     '********************** ARGUMENT LIST *************************
     '(x%, y%)      the point at which to begin flood filling
     'c%            the color to fill with
     '**************************************************************
     IF POINT(x%, y%) = c% THEN EXIT SUB ELSE PSET (x%, y%), c%
     n% = 1
     l& = 1
     OPEN "fill.bin" FOR BINARY AS #1
     DO
          IF POINT(x% + INT(n% MOD 2 + 2 * (n% = 1)), y% + INT(n% MOD 2 XOR 1 + 2 * (n% = 2))) <> c% AND (ABS(159.5 - (x% + INT(n% MOD 2 + 2 * (n% = 1)))) < 160) AND (ABS(99.5 - (y% + INT(n% MOD 2 XOR 1 + 2 * (n% = 2)))) < 100) THEN
               x% = x% + INT(n% MOD 2 + 2 * (n% = 1))
               y% = y% + INT(n% MOD 2 XOR 1 + 2 * (n% = 2))
               PSET (x%, y%), c%
               PUT #1, l&, n%
               l& = l& + 2
               n% = 1
          ELSE
               IF n% < 4 THEN
                    n% = n% + 1
               ELSE
                    IF l& > 1 THEN
                         l& = l& - 2
                         GET #1, l&, n%
                         x% = x% - INT(n% MOD 2 + 2 * (n% = 1))
                         y% = y% - INT(n% MOD 2 XOR 1 + 2 * (n% = 2))
                         n% = n% - (n% < 4)
                    ELSE
                         EXIT DO
                    END IF
               END IF
          END IF
     LOOP
     CLOSE #1
     KILL "fill.bin"
END SUB


*peace*

Meg.
Logged
Meg
Ancient QBer
****
Posts: 483


.
« Reply #18 on: July 18, 2003, 12:13:40 AM »

when does this challenge end?
Logged
Mango
Wandering Guru
***
Posts: 360



« Reply #19 on: July 18, 2003, 12:47:13 AM »

Quote from: "Meg"
I'd much rather have used recursion, but here is my non-recursive entry...



Meg...I think that "lowercase L" is an unfortunate name for a variable...for code posted to the web...it occupies the *exact* same pixel pattern as the numeral "1" in my web browser... Sad

Btw...nice code you've been doing...I now see why you were asking about Binary files a day or 2 ago Smiley
Logged
Meg
Ancient QBer
****
Posts: 483


« Reply #20 on: July 18, 2003, 02:01:09 AM »

haha and I accidentally left it out of the variable list/explanation up top, too :p

thanks Smiley

yeah I was asking about binary files because I didn't want to have to store the paint path in an array because it could easily overflow for certain patterns.

plus, I needed to learn about binary sooner or later Wink

*peace*

Meg.
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!